Results 1 to 4 of 4

Thread: Make the Floating Top Bar script "static" on click?

  1. #1
    Join Date
    Jun 2007
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Make the Floating Top Bar script "static" on click?

    1) Script Title: Floating Top Bar Script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/floatbar.htm

    3) Describe problem:

    Hi! I have combined the Dynamic Ajax Content script with the Floating Bar script so that when a user clicks a dynamic ajax link content is magically loaded into the floating div. You can see the scripts working together in harmony here: http://www.room117.com/sandbox/menu.php

    Is there a way to stop the floating top bar script from moving if it contains content? In other words, how can I temporarily disable the "topbar" div from scrolling?

    Thanks in advance for any leads!

  2. #2
    Join Date
    Jun 2007
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    One solution that I tried was to modify this line:

    Code:
    ftlObj.y += (pY + startY - ftlObj.y)/8;
    to:

    Code:
    ftlObj.y += (pY + startY - ftlObj.y);

    This makes the div float in virtually the same spot no matter where the user scrolls. However, I would prefer to find a solution where the eventListener is toggled on/off so the div becomes static.

    Any thoughts? Thanks in advance!

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

    Default

    Okay! I figured it out---one solution, anyway. Probably not perfect, but it works.

    Here's the starting point:

    http://www.room117.com/sandbox/menu.php

    Here's the version that's working how I'd like:

    http://www.room117.com/sandbox2/menu.php

    **

    I first changed:

    Code:
    setTimeout("stayTopLeft()", 10);
    to

    Code:
    t=setTimeout("stayTopLeft()", 0);
    then added in two functions to the javascript code:

    Code:
    function stopMove()
    {
    if (q == 1) {startMove();}
    clearTimeout(t);
    q=1;
    }
    
    function startMove()
    {
    stayTopLeft();
    q=0;
    }
    That did the trick. Expert feedback and modifications are welcome. Thank you.

  4. #4
    Join Date
    Jun 2007
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Sorry to continually bump my own thread but I also declared the variable q in the revised version of the script. E.g.,

    Code:
    var startX = 515 //set x offset of bar in pixels
    var startY = 130 //set y offset of bar in pixels
    var q = 0 //variable to control start and stop functions
    I hope that clears up any questions.

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
  •