PDA

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



snapple_pitchcock
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!

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


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

to:


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!

snapple_pitchcock
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:

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:


setTimeout("stayTopLeft()", 10);

to


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

then added in two functions to the javascript 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.

snapple_pitchcock
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.