View Full Version : Make the Floating Top Bar script "static" on click?

06-15-2007, 06:38 AM
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!

06-18-2007, 04:26 AM
One solution that I tried was to modify this line:

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


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!

06-18-2007, 06:48 AM
Okay! I figured it out---one solution, anyway. Probably not perfect, but it works. :)

Here's the starting point:


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



I first changed:

setTimeout("stayTopLeft()", 10);


t=setTimeout("stayTopLeft()", 0);

then added in two functions to the javascript code:

function stopMove()
if (q == 1) {startMove();}

function startMove()

That did the trick. Expert feedback and modifications are welcome. Thank you.

06-18-2007, 07:08 AM
Sorry to continually bump my own thread but I also declared the variable q in the revised version of the script. E.g.,

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.