Results 1 to 4 of 4

Thread: Cmotion Gallery Mozilla Bug

  1. #1
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default Cmotion Gallery Mozilla Bug

    http://www.dynamicdrive.com/dynamici...iongallery.htm

    It seems that if this script is used on a page with most doctypes and the width of the train of images displayed is greater that the window width, Mozilla will default to a rough equivalent of window.innerWidth when calculating the 'actualwidth' variable used for determining how far to scroll left before reaching the end of the image train. This results in the scrolling stopping short of displaying all the images. I came up with an alternate method for calculating this width but, I had to use a 'cosmological constant' to get it to work right, here is the function I came up with:
    Code:
    function findWidth(){
    var combWidth=0
    var inc=-1
    var docImages=document.getElementsByTagName('img')
    for (i = 0; i < docImages.length; i++){
    if (docImages[i].parentNode.parentNode.parentNode.id=='motiongallery'){
    combWidth+=(docImages[i].width+Math.abs(docImages[i].border)*2)
    inc++
    }
    }
    combWidth+=(inc)*4 // 'cosmological constant'
    return combWidth
    }
    This 'cosmological constant' represents the additional space between image elements after their borders have already been taken into account. I don't know where it comes from exactly, or how to access it more directly. Any thoughts?

    Anyways, to my surprise, this function also worked in IE and Mozilla with or without a doctype!

    Added Later:

    That 'cosmological constant' was bothering me, so after a trip to the DOM inspector, I realized that it was partly to be accounted for in the borders of the anchor elements containing the images. I also noticed that there was another element between the images and the id'd container, the <nobr> element. I then discovered that if this element was given an id and accessed for its offsetWidth, it returned the correct value. Therein lies the real fix for this script. Give that <nobr> tag on the display page an id and access its offsetWidth in the script to get the actualwidth variable.
    Last edited by jscheuer1; 06-26-2005 at 08:10 AM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    http://www.dynamicdrive.com/forums/s...ad.php?p=11490

    Gives a simpler explanation of the fix. Also, all the code in the script creating and referring to the span with the id of 'temp' can be removed.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Very nice jscheuer1! Thanks for tirelessly investigating and posting a fix. I'll test out the code referred to in your other thread, along with another idea I have for overcoming the problem, and update the script once that's done.

    Thanks!

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    I've gone ahead and updated the script with the fix as suggested by jscheuer1 in this thread. Thanks again for the code.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •