PDA

View Full Version : Width Bug in Advanced Gallery script



novalis
05-02-2005, 10:48 AM
Hi,

it took me 3 hours to figure out this bug... actually the Gecko-Engine returns only the visible part of a DIV-Layer when you try to get its offsetWidth.

I spotted a workaround in the mozilla bugtracker, and used a function mentioned there to get around this bug... this works fine for me:



function getContentWidth(el){
var tmp=el.style.overflow
el.style.overflow='auto'
var w=el.scrollWidth
el.style.overflow=tmp
return w
}

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
document.getElementById("temp").innerHTML=cross_scroll.innerHTML //NEW stuff
actualwidth=document.all? cross_scroll.offsetWidth : getContentWidth(document.getElementById("temp"))
if (!window.opera) document.getElementById("temp").style.display="none"

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

crossmain.onmouseout=function(e){
stopmotion(e)
showhidediv("hidden")
}
}
loadedyes=1
if (endofgallerymsg!=""){
creatediv()
positiondiv()
}
}


Greetz, Novalis
www.exanto.de

ddadmin
05-02-2005, 07:40 PM
Script referred to: http://www.dynamicdrive.com/dynamicindex17/agallery.htm

I see what you're doing in the above code, though can you describe the bug in more detail and in which browsers (ie: Mozilla, Firefox etc) it occurs in? Nice technique, though I don't see where Advanced Gallery script needs to get the actual content width of its subject.

novalis
05-12-2005, 11:04 AM
Hi,

the bug occurs in the current Gecko-Engine, so Mozilla is likely affected as well. I just tested in Firefox, and the bug occured there.

The script needs to get the width of the content to start / stop / scroll the scrolling. So when you scroll to the right (with a lot of images in the scroller) it will stop at the actual screen size (ie 1280px on my screen), because Gecko returns the width of the visible part only. To rebuild the bug you need to have pictures / content with a width > your actual horizontal screen width.

I hope this helps! My english isn't the best, so I'm missing some expressions to describe it better ;-)

Greetz,
Novalis