Results 1 to 7 of 7

Thread: Delay start of C Motion Gallery script?

  1. #1
    Join Date
    Oct 2008
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Delay start of C Motion Gallery script?

    1) CMotion Image Gallery

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

    3) I love this script, thank you! I have set up the script to begin scrolling automatically, and I am wondering if it is possible to add a delay after the page loads, and before the images start to scroll. Any help with this will be much appreciated.

  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

    Yes, pretty much. A delay could be introduced (using the setTimeout() method) between when it is ready to scroll and when you cause it to scroll automatically. The specifics of that would depend upon what code you use to make it begin scrolling automatically. What code is that?
    - John
    ________________________

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

  3. #3
    Join Date
    Oct 2008
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I set this variable:

    var running=1

  4. #4
    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

    Quote Originally Posted by procyan View Post
    I set this variable:

    var running=1
    That is not enough in and of itself to accomplish the task of setting cmotion into motion without user interaction. There must be other modifications to the code to support it, as running isn't even a variable in the default version of the cmotion script and has no relation to it. In fact, running being declared in that fashion almost certainly implies that it is later code that actually implements a directive to start moving, based upon running as a boolean flag.

    So I probably still need to see the full code used for that, or perhaps even the entire modified script. It would be best (if it comes to that) if you would explain all modifications you made to the script to make it "begin scrolling automatically", and provide a link to a demo:

    Please post a link to the page on your site that contains the problematic code so we can check it out.


    That said, if we're lucky, you can just replace:

    Code:
    var running=1
    with:

    Code:
    var running;
    setTimeout(function(){running = 1;}, 1000);
    where 1000 is the delay in milliseconds before the function in the timeout fires. But for the reasons mentioned, I seriously doubt that will work out well. Though anything is possible, depending upon the rest of the code.
    - John
    ________________________

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

  5. The Following User Says Thank You to jscheuer1 For This Useful Post:

    procyan (12-18-2008)

  6. #5
    Join Date
    Oct 2008
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thank you for your help with this!

    A test page is loaded here: http://fletcherandwilder.com/tm/test.html

    The Cmotion Gallery script is here: http://fletcherandwilder.com/tm/motiongallery2.js

    I didn't think I did any modifications to the script at all.

    You are right - the var running;
    setTimeout(function(){running = 1;}, 1000); modification does not affect the script action.

  7. #6
    Join Date
    Oct 2008
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Actually, it does seem to be delaying now with that modification, I must not have cleared the cache correctly.

    Thank you!

  8. #7
    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

    You didn't modify the script, I did. But you didn't mention you were using a version modified by someone else. Anyways, go back to just:

    Code:
    var running=1
    Then at the end of the fillup function, find:

    Code:
    loadedyes=1
    if (running){
    scrollspeed=defaultspeed
    moveleft()
    }
    }
    Change it to:

    Code:
    loadedyes=1
    if (running){
    scrollspeed=defaultspeed;
    fillup.timer = setTimeout(moveleft, 1000);
    }
    }
    Where 1000 is the delay in milliseconds. You should also add here to both functions as shown:

    Code:
    function moveleft(){
    if (iedom&&loadedyes){
    if(fillup.timer)
    clearTimeout(fillup.timer);
    movestate="left"
    if (parseInt(cross_scroll_0.style.left)<(-actualwidth))
    cross_scroll_0.style.left=parseInt(cross_scroll_1.style.left)+actualwidth+"px"
    if (parseInt(cross_scroll_1.style.left)<(-actualwidth))
    cross_scroll_1.style.left=parseInt(cross_scroll_0.style.left)+actualwidth+"px"
    cross_scroll_0.style.left=parseInt(cross_scroll_0.style.left)-scrollspeed+"px"
    cross_scroll_1.style.left=parseInt(cross_scroll_1.style.left)-scrollspeed+"px"
    //showhidediv("visible")
    }
    lefttime=setTimeout("moveleft()",100)
    }
    
    function moveright(){
    if (iedom&&loadedyes){
    if(fillup.timer)
    clearTimeout(fillup.timer);
    movestate="right"
    if (parseInt(cross_scroll_0.style.left)>0)
    cross_scroll_1.style.left=parseInt(cross_scroll_0.style.left)-actualwidth+"px"
    if (parseInt(cross_scroll_1.style.left)>0)
    cross_scroll_0.style.left=parseInt(cross_scroll_1.style.left)-actualwidth+"px"
    cross_scroll_0.style.left=parseInt(cross_scroll_0.style.left)+scrollspeed+"px"
    cross_scroll_1.style.left=parseInt(cross_scroll_1.style.left)+scrollspeed+"px"
    }
    righttime=setTimeout("moveright()",10)
    }
    - John
    ________________________

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

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
  •