images on Nokia WRT

To avoid imgs flicker in the Nokia WRT you should preload images before they are displayed.
A simple js function for that:

var ImagePreloader = {
list: [],
images: [],
add: function( images ) {
this.list = this.list.concat( images );
},
start: function() {
for (var i = 0; i < this.list.length; i++) {
var img = new Image();
img.src = this.list[i];
this.images.push(img);
}
}
}

function preloadImages() {
ImagePreloader.add( [
"../images/splash.png",
"../images/splash_small.png",
"../images/ProgressBarUnknown.gif",
"../images/pop_up_bg.png",
"../images/shadow.png",
"../images/img-logo_small.png",
"../images/img-branding-background.png",
"../images/disclosure-indicator.png"
] );
ImagePreloader.start();
}

And in your css code you should use the background: url(../images/img-logo_small.png) no-repeat; syntax.

3 thoughts on “images on Nokia WRT

  1. Craig McDonnell

    Hi Danilo! Unfortunately, I’ve not been able to use the above in my case as I have too many images to load into memory at once. I’ve hacked together the following to at least avoid the flicker (though there is still a slight loading delay):

    // uses jQuery 1.4

    var lastImageSrc; // don’t bind to the load event if the image is the last one loaded

    var thisImageSrc = ‘images/whatever.gif’;
    var targetImg = $(‘#target’);
    var flashImage = function() { targetImg.show().fadeOut(‘slow’); };
    if (lastImageSrc != thisImageSrc) {
    lastImageSrc = thisImageSrc;
    targetImg.attr(‘src’, thisImageSource);
    targetImg.bind(‘load’, flashImage);
    } else {
    flashImage();
    }

    Reply
  2. Pingback: 2010 in review | Danilo Ercoli

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s