Page 1 of 6 123 ... LastLast
Results 1 to 10 of 51

Thread: CMotion and FiF issue

  1. #1
    Join Date
    Jun 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default CMotion and FiF issue

    CMotion Image Gallery
    http://www.dynamicdrive.com/dynamici...iongallery.htm

    I have put the script into my page to display ten images. When viewed through IE, the script works fine, but FireFox only wants to show seven and a bit of the images before declaring End Of Gallery.

    I have looked through the code but can't find any limiter of the 'length' of the slideshow (presumably IF there were one it would be in pixels, as the 'last' image diplayed in FF is only partly visible).

    Any idea what the issue might be in FireFox? I haven't checked the page on other browsers yet...

    Many Thanks.

    A.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,127
    Thanks
    44
    Thanked 3,228 Times in 3,189 Posts
    Blog Entries
    12

    Default

    I've run across this a few times before and was searching the archives to see if I could find the solution. I only found one relevant thread but, there, no solution was found. I distinctly remember finding one though, for another fellow. It was a tough case, one where we found a few partial solutions that had drawbacks and I needed to go over the source numerous times. Finally we came up with a workable solution. If you could supply a link to the page in question, I'll give it a crack.
    - John
    ________________________

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

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,127
    Thanks
    44
    Thanked 3,228 Times in 3,189 Posts
    Blog Entries
    12

    Default

    Turn's out the old adage - you learn more from your failures than you do from your successes - is true in this case. I decided to go after this problem using the case I found in the archives that I hadn't been able to solve, as it turns out, a much simpler example. By simply removing the doctype declaration, I was able to fix it. The trouble is that with a doctype of:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    and I am sure, many others, the width calculated by the script for Mozilla based browsers is wrong. So, you can either remove your doctype from the page or, find this line in the script:
    Code:
    actualwidth=document.all? cross_scroll.offsetWidth : document.getElementById("temp").offsetWidth
    and change it to:
    Code:
    actualwidth=document.all? cross_scroll.offsetWidth : number
    substitute for number the actual width of the gallery's train of images, use the number only - no px after it, no quotes around it. Ex:
    Code:
    actualwidth=document.all? cross_scroll.offsetWidth : 1850
    You can find this number by adding together the display width of all the images plus the width of any padding and/or spacing. OR, just temporarily, insert this line just below that line in the unaltered script:
    Code:
    alert(actualwidth)
    view the page in IE and use the value shown in the alert box.
    Last edited by jscheuer1; 06-26-2005 at 04:05 AM. Reason: spelling
    - John
    ________________________

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

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,127
    Thanks
    44
    Thanked 3,228 Times in 3,189 Posts
    Blog Entries
    12

    Default

    I looked into this further and the real fix is to give the <nobr> tag on the display page an id like so:
    HTML Code:
    <div id="motioncontainer" style="position:relative;width:400px;height:150px;overflow:hidden;">
    <div id="motiongallery" style="position:absolute;left:0;top:0;white-space: nowrap;">
    
    <nobr id="trueContainer"><a href . . . snip!
    Then in the original motiongallery.js script, change this line:
    Code:
    actualwidth=document.all? cross_scroll.offsetWidth : document.getElementById("temp").offsetWidth
    to this:
    Code:
    actualwidth=document.all? cross_scroll.offsetWidth : document.getElementById("trueContainer").offsetWidth
    There now, that's alot easier, huh?
    - John
    ________________________

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

  5. #5
    Join Date
    Jun 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    A simple and elegant solution.

    Many thanks for the time you invested in the problem, John. It's much appreciated.

    *runs off to download some more browsers

    A.

  6. #6
    Join Date
    Sep 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem in Firefox

    I downloaded this fantastic script and implemented it on a testpage.
    In IE there are no problems, in Firefox (1.0.5) and Netscape (7.2) i'm receiving the following error :

    on line 112 : b has no properties.
    The used code has been checked with the solutions given on this forumtopic.
    Allthough most of the users are using IE, I would like it to work in all browsers.

    I must admit i'm not an expert in javascript, so if anyone can help ???

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,127
    Thanks
    44
    Thanked 3,228 Times in 3,189 Posts
    Blog Entries
    12

    Default

    Two things at work here and I have some suggestions for refinement. First of all, you broke the 'fix' for this script when you introduced another 'containing element', a table, into the html markup. If you remove id="trueContainer" from the <nobr> tag and apply it to the <table> tag, this will correct that:
    HTML Code:
        <nobr>
    
    		<table id="trueContainer">
    Second, the error you got is just an artifact caused by having another window (perhaps the javascript console itself) over the page. This is not a script breaking error and resolves itself once focus is fully returned to the window this script is in. As for suggestions, in Mozilla and with such a long image train, 7 is too low for maxspeed, so I would suggest using a test at the assignment of that variable like, where it says:
    Code:
    var maxspeed=7 //2) top scroll speed in pixels. Script auto creates a range from 0 to top speed.
    Change it to:
    Code:
    var maxspeed=(document.all&&!window.opera)? 7 : 27 //2) top scroll speed in pixels. Script auto creates a range from 0 to top speed.
    NOTE: This is only needed for a gallery containing so many images and the exact values (7 and 27) can be adjusted as you see fit. The 7 in this case is for IE and the 27 is for Mozilla and Opera (opera untested, may need to be removed from the conditional, take out '&&!window.opera' or change to '||window.opera' if it causes problems in opera.)

    The other suggestion that I have is that if you want the galley centered, enclose the entire html part in a centered element.
    - John
    ________________________

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

  8. #8
    Join Date
    Sep 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thx

    Thank you very much. It's working now in the other browsers too.

  9. #9
    Join Date
    Sep 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hello,

    I use the CMotion Gallery and I also came accross the "b has no properties" Javascript error, but I don't get this error in the same situation than "Soldierflup". It happens on FireFox (1.0.6), Netscape (7.2 & 8.0), when I use the mouse scroll button (to scroll up or down the page), while being over the gallery with the mouse cursor.

    That a really particular case I admit, but maybe someone will be more successful to debug this, I tired but I couldn't find any solution to this :S My guess is that Firefox/Netscape (well Gecko) considers that the mouse moves out of the gallery (although it doesn't in my case, the scrollbar is very small) ... which call the "stopmotion" function. This error doesn't happen in Opera...

    Thanks a lot for your script, and thanks in advance for your answers.

  10. #10
    Join Date
    Sep 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I guess I'll answer my stupid question myself... mabye I'll help other people like me

    Replace :
    Code:
    function contains_ns6(a, b) {
    	if(b) {
    		while (b.parentNode)
    			if ((b = b.parentNode) == a)
    				return true;
    	}
    	return false;
    }
    by :
    Code:
    function contains_ns6(a, b) {
      while (b.parentNode)
        if ((b = b.parentNode) == a)
          return true;
      return false;
    }
    It solves the problem and the script still works in MSIE5.5/MSIE6, FireFox 1.0.6, Netscape 7.2/Netscape 8.0, Opera 7.5 / Opera 8.0 , Safari 1.2.2 and MSIE 5.2 Mac.

    Hope it will help, sorry again

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
  •