Skip navigation
d4u2
Currently Being Moderated

Spry Image Loader

Jan 28, 2009 2:01 AM

Hi,

can i show up a loading bar or image while the images are preloading with the SpryImageLoader?

Thanks for your help!
 
Replies
  • Currently Being Moderated
    Jan 28, 2009 2:40 AM   in reply to d4u2
    Sure why not? I see no reason why not.. As long the image has been loaded before the images are being preloaded..
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 28, 2009 3:14 AM   in reply to d4u2
    Ill hook you up with something. It requires a bit more editing than i thought.

    Ill post back with a solution :)
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 28, 2009 11:58 AM   in reply to d4u2
    Download a new SpryImageLoader: http://www.spry-it.com/builds/SpryImageLoader.js

    example htmlish...

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" " http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns=" http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Untitled Document</title>
    <script type="text/javascript">
    <!--
    var ds1 = new Spry.Data.XMLDataSet("xml/deutsch/index.xml", "imageset/image"),
    loader = new Spry.Utils.ImageLoader(function(){
    loaded = true;
    var rgn = Spry.Data.getRegion('thumbwrapperindex');
    if(rgn)
    rgn.setState('ready');
    }),
    loaded = false;
    ds1.loadData();
    ds1.addObserver({
    onPostLoad:function(ds,data){
    var dataset = ds.getData();
    for(var i = 0, length = dataset.length; i < length; i ++ ){
    loader.load(dataset [ "galerieset/index/images/thumb/" ]);
    }
    }
    });

    var pv1 = new Spry.Data.PagedView( ds1,{pageSize:50});
    var pvInfo = pv1.getPagingInfo();
    Spry.Data.Region.addObserver("thumbwrapperindex", {
    onPostUpdate: function() {
    if(!loaded){
    var rgn = Spry.Data.getRegion('thumbwrapperindex');
    if(rgn)
    rgn.setState('loadingThumbs');
    } else {
    Lightbox.init({descriptions: '.lightboxDesc'});
    }
    }
    });

    //-->
    </script>
    </head>

    <body>
    <div spry:region="pv1" id="thumbwrapperindex">
    <div spry:state="loadingThumbs">
    Loading thumbs please wait.. message
    </div>
    <div spry:state="ready">
    Stuff that needs to be shown after the images are loaded..
    </div>
    </div>
    </body>
    </html>



    Example code, notice the spry:states in the spry:region

    I didn't test it because I don't have access to any on this laptop -_-"
    *crosses fingers*

    What it should do:

    when the xml has been loaded, we loop through the data, and load the image locations in the Spry Image Loader. I have modified the Spry Image loader that it allows a callback when all images have been loaded. We will use this new callback to set states of your region.

    You can now have a separate state in your region that shows a loading message. And the ready state will show when the data has been loaded.

    EDIT TO GET THE FULL CODE, QUOTE MY POST, AND COPY THE CODE FROM THE REPLY BECAUSE THE FORUM SEES MY CODE AS A ITALIC STYLE CODE.. oh ignore the caps, didnt notice it was on and im currently not in the mood to retype it all again ;)
     
    |
    Mark as:
  • Currently Being Moderated
    Feb 15, 2009 6:52 PM   in reply to Arnout Kazemier
    I tried your solution and it didn't cause any errors on my page (that's a good thing). However, it didn't exactly pre-load the images that I needed it to. It just kept on doing the same behavior.

    The page that I'm working on needs to load the main image once it has been fully downloaded. Right now, it starts the page and you can see the image downloading. Take a look at http://dev.georgerausch.com/knd/. Then go into the Logo, Print, or one of the other design sections. If you page through the portfolios, you'll see that it isn't working well causing blips in between the paged images.

    Is there some modification that I need to make to this code? I obviously changed all of the VARs and other IDs to match what I need, but that still didn't work. Any suggestions on what I need to do with my code?
     
    |
    Mark as:
  • Currently Being Moderated
    Feb 16, 2009 12:38 AM   in reply to d4u2
    I really don't see the page where you had implemented this code. I check your source codes and i see no includes of the spryimageloader, or any other custom code expect the constructor of your dataset and Spry Effects.

    And i see you want to implement a gallery like type. Did you check out the demo page? it also contains a spry gallery

    http://labs.adobe.com/technologies/spry/demos/
     
    |
    Mark as:
  • Currently Being Moderated
    Feb 16, 2009 1:10 AM   in reply to Arnout Kazemier
    Sorry, I removed the code, but it is now back and still not causing errors, but not working as anticipated. The reason why I didn't use a regular gallery was because I needed a picture to load in one spry:region and have information in a details in a spry:detailregion. I just started to read about Spry last Friday and have been working diligently through the weekend to make things work.

    IF you look on this page (now with your code), http://dev.georgerausch.com/logo.php, you'll see that I am trying to make the image load before the fade effect even begins. In addition, in the lower section, you will notice that there are details that pertain to that exact image.

    I did look over the gallery examples and the coding is a little bit over my head (right now). Please advise on whether what I want to do can be accomplished with a gallery, or whether I need to figure out how to use the SpryImageLoader.js in conjunction with SpryPagedView.js. Again, I need to have an image and then a spry:detail region with the information that pertains to the image on that specific page. Thank you for all of your help.
     
    |
    Mark as:
  • Currently Being Moderated
    Feb 16, 2009 1:43 AM   in reply to d4u2
    I've actually taken another solution from another entry. But thank you for your assistance.

    The code I used is as follows:

    <script type="text/javascript">
    <!--

    var dsLogos = new Spry.Data.XMLDataSet("data/logos.xml", "logos/logo", {useCache: false });
    var pv1 = new Spry.Data.PagedView( dsLogos ,{pageSize: 1});

    var loader = new Spry.Utils.ImageLoader();

    function MyPreloadFilter(ds, row, rowIndex)
    {
    loader.load(row[ "image" ]);
    return row;
    }

    dsLogos.filterData(MyPreloadFilter);


    //-->
    </script>

    It worked perfectly.
     
    |
    Mark as:
  • Currently Being Moderated
    May 10, 2012 1:52 PM   in reply to Arnout Kazemier

    new js link is not working, thxx

     
    |
    Mark as:
  • Currently Being Moderated
    May 17, 2012 1:28 AM   in reply to Malacool

    i need the small image preloading for imagea in XMLDataSet... so far i m unable to get the help and related material regarding this..

     

    Thanks for your reply...

     
    |
    Mark as:
  • Currently Being Moderated
    May 17, 2012 3:44 AM   in reply to d4u2

    Sure it would help me alot... my sample site can be view here

    http://al-wadood.edu.pk/wbrothers/index.php?section=subhead&page=5&mai nhead=2

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points