Click to See Complete Forum and Search --> : Show/hide layers stalls animated gif
ragawu
03-30-2003, 09:04 AM
Just wondering if anyone has encountered this problem and found a solution.
I am using DHTML to show/hide layers on mouseover events. When I mouseover all the animaed gifs of a graphically intensive page stop for the period until the layer's visibility is changed. ie 1 second. This pause is unnacceptable to me.
Does anyone know of a show/hide layers script which doesnt slow the browser down? I also tried a script that set the text of layers instead of changing visibility of layers, but this was even slower.
thanks!
alasdair
here is the page in action:
http://www.lapsuslinguae.co.uk/hometest.htm
bouwteam
03-30-2003, 02:39 PM
i guess the rendering of the page stops shortly when javascript is calculating what to do with it's layers etc.. That is no problem if you have 'light' scripts. The scripts that you use are really heavy. I don't know if you looked into the code but for every layer that needs to be hidden or showed i goes through your whole document to search for the appropiate layer!! that takse a lot of time. If you build simpler code it will cost less time and you will notice that the laps in the animated gifs gets a lot smaller. If you want hints on building the lighter code let me know.
good luck
ragawu
03-31-2003, 04:35 AM
There seems to be people here that know what they're talking about :)
OK, so what I'm lookign for is a light script..where do I find one? I'm not a Javascript programmer - more interested bystander.
I like the idea of running the light script bouwteam, but asynchonously like dave clark mentions. As I'm pretty ignorant of even the very basic javasrcipt I'd need more explanation on
onmouseover="return eventHandler(this);"
can be changed to the following for the purpose described above:
onmouseover="currentObject=this; setTimeout('eventHandler()',5); return true;"
The function just needs to reference the global variable for its object information. Information from the Event object would have to be copied some other way because the Event object (at least, in IE) does not exist after the event ends.
thanks for your help. I'm actually really interested in javascript, but I'm at a stage where I'm slowly picking it up along with asp and perl. Not ready to embark on studying it yet.
Alasdair
ragawu
03-31-2003, 11:17 AM
This is the javascript for the mouseovers:
onMouseOver="MM_showHideLayers('diary','','show','destiny','','hide')" onMouseOut="MM_showHideLayers('diary','','hide','destiny','','show')"
diary is the name of the layer I want to show while mousover and destiny is the name of the layer I want to hide while mouseover. They should return to origonal parameters after mouseout, hence the second part.
This is the function and it's included functions:
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v6.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; }
}
These are the standard mousovers that come with Dreamweaer mx. IF someone can point me in the right direction of a "light" script I would be much appreciative! Then I can figure out a way of running it asynchornously, thereby removing any delay whatsoever.
thanks again
alasdair
ragawu
03-31-2003, 07:25 PM
I managed to find a function that was much smaller, but the animated gifs still pause for half a second. I would like complete seperation. Why can't my reasonably powerful pc run both these prcedures at the same time?
alasdair