Thread: Add load event to Ext.net.Image

+ Reply to Thread
  1. #1
    Premium Member
    Join Date
    Apr 2008
    Posts
    808

    Add load event to Ext.net.Image

    It would be awesome if you guys can add a load event to Ext.net.Image. I have an image that hits a httphandler that generates a graph. This can sometimes take a while so I would like to mask the image's container while the image is loading. Currently, I have to manually add masking code every time I call setImageUrl. It would be easier if I can just listen to a load event before the url is set. I am already listening to the complete event to unmask.

    Or if you guys add a Mask config to Ext.net.Image that will do the masking and unmasking internally, that would be even better =).

  2. #2
    Ext.NET - Dev Team
    Join Date
    Mar 2008
    Location
    Russia
    Posts
    8,452
    Hi,

    Ok, I will add it today/tomorrow
    Vladimir Shcheglov
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext JS API Docs | Twitter

  3. #3
    Premium Member
    Join Date
    Apr 2008
    Posts
    808
    any updates on this? thanks!

  4. #4
    Ext.NET - Dev Team
    Join Date
    Jan 2008
    Location
    Canada
    Posts
    5,269
    Hi Jacky,

    The <Complete> Listener and DirectEvent has been added. Please update from SVN.

    Example

    <ext:Image ID="Image1" runat="server" ImageUrl="http://forums.ext.net/image.php?u=52&dateline=1278319354">
        <Listeners>
            <Complete Handler="console.log('Complete', arguments);" />
        </Listeners>
    </ext:Image>
    Hope this helps.
    Geoffrey McGill
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext JS API Docs | Twitter

  5. #5
    Ext.NET - Dev Team
    Join Date
    Jan 2008
    Location
    Canada
    Posts
    5,269
    oops... maybe I was mistaken.

    A new <BeforeLoad> Listener and DirectEvent will be added shortly, as well as new LoadMask functionality.

    We'll post and update once complete and committed to SVN.
    Geoffrey McGill
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext JS API Docs | Twitter

  6. #6
    Ext.NET - Dev Team
    Join Date
    Mar 2008
    Location
    Russia
    Posts
    8,452
    Hi,

    We have added the following functionality to the Image
    - BeforeLoad event
    - LoadMask property (automatic masking can be a problem because html image cannot have child element therefore we cannot mask an image directly, we have tested LoadMask with several cases and appears it works correctly but if you find a problem test case then please post it)
    Vladimir Shcheglov
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext JS API Docs | Twitter

  7. #7
    Premium Member
    Join Date
    Apr 2008
    Posts
    808
    Quote Originally Posted by vladsch View Post
    Hi,

    We have added the following functionality to the Image
    - BeforeLoad event
    - LoadMask property (automatic masking can be a problem because html image cannot have child element therefore we cannot mask an image directly, we have tested LoadMask with several cases and appears it works correctly but if you find a problem test case then please post it)
    Thanks vladsch! The BeforeLoad event works great. I also tried the LoadMask property but it doesn't fit my requirements. I have an image inside a panel. On a button click, I load a bigger image with new url but the panel doesn't resize itself. If I do custom masking using BeforeLoad event, the panel resizes correctly. Not a big deal as I am able to accomplish what I did using BeforeLoad, but just wanted to point it out.

    Example - you can use any images for ChartBig.bmp and ChartSmall.bmp as long as they are different size. I also attached a screenshot after I clicked hte Load New Image buttons.

    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ScriptMode="Debug" runat="server">
        </ext:ResourceManager>
        <ext:Panel runat="server" Title="Image With Built-in Load Mask">
            <Buttons>
                <ext:Button ID="Button1" runat="server" Text="Load New Image">
                    <Listeners>
                        <Click Handler="imgOne.setImageUrl('ChartBig.bmp')" />
                    </Listeners>
                </ext:Button>
            </Buttons>
            <Items>
                <ext:Image runat="server" ID="imgOne" ImageUrl="ChartSmall.bmp">
                    <LoadMask ShowMask="true" />
                </ext:Image>
            </Items>
        </ext:Panel>
        <ext:Panel ID="Panel1" runat="server" Title="Image With Custom Load Mask">
            <Buttons>
                <ext:Button ID="Button2" runat="server" Text="Load New Image">
                    <Listeners>
                        <Click Handler="imgTwo.setImageUrl('ChartBig.bmp')" />
                    </Listeners>
                </ext:Button>
            </Buttons>
            <Items>
                <ext:Image runat="server" ID="imgTwo" ImageUrl="ChartSmall.bmp" MonitorComplete="true">
                    <Listeners>
                        <BeforeLoad Handler="if (Panel1.rendered) {Panel1.getEl().mask('loading');}" />
                        <Complete Handler="Panel1.getEl().unmask();" />
                    </Listeners>
                </ext:Image>
            </Items>
        </ext:Panel>
        </form>
    </body>
    </html>
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	images.png
Views:	26
Size:	61.2 KB
ID:	1409  

  8. #8
    Ext.NET - Dev Team
    Join Date
    Mar 2008
    Location
    Russia
    Posts
    8,452
    Hi,

    Fixed in SVN
    Vladimir Shcheglov
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext JS API Docs | Twitter

+ Reply to Thread