View Full Version : How to avoid any fade duration during slide transition

12-14-2013, 06:13 PM
1) Script Title: Simple Controls Gallery

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/simplegallery.htm

I am using the gallery to display weather maps (gif/png images) in a loop. When transitioning from one slide (image) to the next, I don't want to there to be any fade...just an instant display of the next slide. I tried placing the fadeduration down to 1 ms, but there's still an "annoying" flash between images in the loop. I tried setting this to zero and I'm getting no images to display at all when it is at zero. Sometimes the first run through the loop is fine and then the next run flashes between slides. Makes it hard to see details/changes between slides (important for weather map displays).

Any help would be appreciated.

Here's a little code snipit.

var mygallery=new simpleGallery({
wrapperid: "simplegallery1", //ID of main gallery container,
dimensions: [x_dimension, y_dimension], //width/height of gallery in pixels. Should reflect dimensions of the images exactly
imagearray: [ <?php for($index=0;$index<sizeof($xml->TAB[$p_index]->IMAGE);$index++)
[<?php if($xml->TAB[$p_index]->IMAGE[$index]->URL != '' && url_validate($xml->TAB[$p_index]->IMAGE[$index]->URL)){?>"<?=$xml->TAB[$p_index]->IMAGE[$index]->URL?>",<? } else {?> "http://<?=$_SERVER['HTTP_HOST']?>/wx/photo_not_available.jpg", <? } ?> <?php if($xml->TAB[$p_index]->IMAGE[$index]->LINK != '')
{ ?> "<?=$xml->TAB[$p_index]->IMAGE[$index]->LINK?>", <? } else { if(!empty($xml->TAB[$p_index]->IMGGENERICLINK)){?> "<?=$xml->TAB[$p_index]->IMGGENERICLINK?>", <? } else {?> "nolink", <?} } ?> "_new", <?php if($xml->TAB[$p_index]->IMAGE[$index]->LABEL!=''){?>"<?=$xml->TAB[$p_index]->IMAGE[$index]->LABEL?>",<?php } else {?> " ",<?php } ?>""]<?php if($index<sizeof($xml->TAB[$p_index]->IMAGE)-1){?>,<? } ?>
<? } ?>

autoplay: [false, delay, 2], //[auto_play_boolean, delay_btw_slide_millisec, cycles_before_stopping_int]
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 1, //transition duration (milliseconds)
oninit:function(){ //event that fires when gallery has initialized/ ready to run
//Keyword "this": references current gallery instance (ie: try this.navigate("play/pause"))
onslide:function(curslide, i){ //event that fires after each slide is shown
//Keyword "this": references current gallery instance
//curslide: returns DOM reference to current slide's DIV (ie: try alert(curslide.innerHTML)
//i: integer reflecting current image within collection being shown (0=1st image, 1=2nd etc)

12-14-2013, 06:33 PM
I'm not getting any 'flash' at fadeduration 1 in Google Chrome. What browser(s) are you using? What can happen is, if images are updated and/or new, you will see white or some other solid color while the image loads. But you say this problem is more common the 2nd time around. Are the images cached at that point, or do they continue to update with current weather conditions?

If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.

12-14-2013, 11:31 PM

I'm using the latest version of Chrome on Windows 7 and Vista. The images are static and don't get updated. My website requires a subscription, but you can see the result in this video here:


12-15-2013, 12:08 AM
Give me a free subscription. To do so, respond here, then PM me the details. You must respond first though, otherwise your post count will be too low to qualify for PM privileges.

I ask because the video is ambiguous. It looks like the images aren't loading in time. But it could be something else. I would have to see the actual page to know for sure. If it's only that the images aren't loading in time, they can probably be preloaded.

12-15-2013, 02:14 AM
Okay, I'll send you a pm with the details.

12-15-2013, 02:19 AM
Tried to PM you and it says that I don't have the privileges.

12-15-2013, 02:30 AM
sdenn you're now a Junior Coder and you're able to send John that PM.

12-15-2013, 02:35 AM
Thanks. PM Sent.

12-15-2013, 03:21 PM
OK I got that and have been looking over what it does. It appears to be browser dependent. And of the browsers I've looked at it in, Chrome is the worst. It looks like there is no caching of the images. But I'm not sure that's the issue. What I would suggest is using a different script. Here are the two that I would recommend considering for this:




The first one would have to be tweaked to provide a stop/start button, but that's simple enough. Its advantage is that its setup is very similar to what you're used to with Simple Controls Gallery. The advantage that either of these scripts have over Simple Controls, is that they're less likely to need to reload the image each time. The first because all of its scripted images remain in the DOM (in Simple Controls these come and go). In the second one they come and go as well, but the way that slideshow works might be smoother. BTW, in browsers which cache the images and type convert null (Opera and Firefox), the current script is smooth.

12-15-2013, 05:47 PM

Chrome and Safari (on my iPad) flash pretty bad. I'll take a look at the first script to see how much effort this will be for my developer. Thanks for your help.

12-15-2013, 06:19 PM
I've been testing it out, and the first one (Ultimate Fade) is much smoother in Chrome for these images. And can be easily adapted:




for how.

12-15-2013, 08:32 PM
Would be interesting to see what that looks like at 1 ms of fadeduration. In my case, the fade aspect of this is also just as bad as the flash.

12-16-2013, 01:39 AM
The fadeduration can also be set to 1 with this (Ultimate Fade) script. Something like (needs more refinement):


However, the fade transition isn't really all that bad (I first tried it with it). It shows the change from image to image.

OK, I've refined it a bit and made another one with navigation/indicator buttons:


And here it is with a fade:


Looks pretty good to me.

12-16-2013, 10:37 PM

Wonderful. The last one that fades is quite difficult to use (cute for showing off, but not practical). I like the one in the middle. You say this middle one uses the simple gallery? I'm not seeing any flashing with Chrome even though you have this set to 1 ms.

It's interesting that my main weather section (the maps that come up before you type in that airport identifier) doesn't have this flashing issue even though I have it set to 1 as well (and that uses the simple gallery too). It's only the airport specific implementation that has this problem. I wonder if there's not something else going on here.

12-17-2013, 12:35 AM
By the way, do you happen to have the source code for that middle example you can share?

12-17-2013, 12:57 AM
It's a little confusing because I started storyboarding this in the simple gallery folder and using that script, but it just wasn't working. I left the page(s) there though as I changed over to Ultimate Fade in script. All three of the demos from my last post use the Ultimate Fade in Slideshow. Although they should work with the official version of the script, I recommend my unofficial version (right click and 'Save As'):

fadeslideshow.js (http://home.comcast.net/~jscheuer1/side/demos/ufade/fadeslideshow.js)

You should grab this image as well:


The other images are copies of your buttons and the weather maps. The green buttons are input tags generated by the script.

The rest of the code is on the page*. Use your browser's "View Source" to get it.

You may have to change some paths and/or filenames. And you may want to make the css external. If you need more help, just ask.

*except for the fading one, which you said you didn't want. It uses another script in addition to fadeslideshow.js, onbeforeslide.js