PDA

View Full Version : Cmotion Gallery - Download Interrupt



Jonno
01-17-2006, 03:41 AM
http://www.dynamicdrive.com/dynamicindex4/cmotiongallery.htm

Hi John and thanks for this wonderful script. I have found a small bug that I wondered if you would be interested in having a look at it? I am using the continuously scrolling version of the cmotion gallery script + all latest tweaks

If a surfer clicks on one of the gallery images before the complete gallery has downloaded, the expected javascript window appears as intended. Upon closing the new window, I find the gallery has stopped downloading when the pop-up window opened - and since it is not fully populated, the gallery will not revolve either

I am explaining this badly - please have a look
http://www.pearl-dragon.com/Furniture/Furniture_Garden.htm
is as good a page as any I guess, the site is in test and build mode at present

I know that surfers will click an image as they wait for the whole gallery to download, and wondered if there was a way to either:
1. Force the gallery to continue downloading after the javascript call
2. Incorporate a 'loading bar' into the script

I have tried the second option, but I was obviously not doing it correctly and ended up with many conflicts

best wishes + many thanks
Jonno

jscheuer1
01-17-2006, 06:19 AM
Since this script already has a variable for checking the load state of the page, 'loadedyes', I'd first try something straightforward like:


function enlargeimage(path, optWidth, optHeight){ //function to enlarge image. Change as desired.
if (loadedyes==0)
return;
var actualWidth=typeof optWidth!="undefined" ? optWidth : "600px" //set 600px to default width
var actualHeight=typeof optHeight!="undefined" ? optHeight : "500px" //set 500px to default height
var winattributes="width="+actualWidth+",height="+actualHeight+",resizable=yes"
window.open(path,"", winattributes)
}

This should prevent the enlargeimage() function from opening a window until the images are loaded. If so, problem solved!

BTW, you're welcome for any modifications of mine to this script that you are using but, I didn't write the original.

Jonno
01-18-2006, 11:32 AM
Hiya - you are correct in that this modification stops the enlargeimage () opening the window. Unfortunately the page download still stops, presenting the user with the appearance of a frozen screen. I did try adding
if (loadedyes==0)
return;
else (loadedyes==1)

But so far I cannot force the page download to continue regardless of whether an enlarheimage() window is called or not

I am going to see if I can wrap this javascript inside a loading bar code, which keeps the gallery invisible untill the download is complete, and then call it with something like
if (loadedyes==0)
show gallery;

Apologies, I am hopeless with code
Oh, I am using xp and IE6 as default, and FF1 for secondary browser checking, plus the site is on a commercial host

many thanks
Jonno

jscheuer1
01-18-2006, 08:07 PM
You could also try changing every instance of:


href="javascript:enlargeimage('some.gif')"

to:


href="javascript:if(loadedyes)enlargeimage('some.gif')"

With this approach and the one I will mention below, you would not need the previous modification I mentioned.

Yet another separate approach would be to make the gallery invisible until loaded. Put this code after the do not edit line in the script:


////NO NEED TO EDIT BELOW THIS LINE////////////

document.write('<style type="text/css">#motioncontainer {visibility:hidden;}<\/style>')

and this line after the loadedyes=1 statement in the fillup() function (addition red):


function fillup(){
if (iedom){
crossmain=document.getElementById? document.getElementById("motioncontainer") : document.all.motioncontainer
menuwidth=parseInt(crossmain.style.width)
mainobjoffset=getposOffset(crossmain, "left")
cross_scroll=document.getElementById? document.getElementById("motiongallery") : document.all.motiongallery
actualwidth=document.all? cross_scroll.offsetWidth : document.getElementById("trueContainer").offsetWidth

crossmain.onmousemove=function(e){
motionengine(e)
}

crossmain.onmouseout=function(e){
stopmotion(e)
showhidediv("hidden")
}
}
loadedyes=1
document.getElementById('motioncontainer').style.visibility='visible'
if (endofgallerymsg!=""){
creatediv()
positiondiv()
}
}

Jonno
01-19-2006, 04:41 PM
Hi John - You are the man! I have gone with the final offering and kept the gallery hidden until loaded - it works a treat!

Many thanks for your time and help, I very much appreciate it
Jonno