I’m in the process of building a timeline, but i’ve run into a bit of a problem with my slider. in the example (UPDATE: http://jsfiddle.net/WMnsc/3/ ) every time i slide the green div the div “holder” slides in the direction of the green div. the holder div contains a div for each li in the timeline which represents a year.
i’m using multiplication to calculate the speed of the “holder” div so the years line up correctly which is working but what i need is for the sliding to slow down when the green div is sliding over a decade and then resume it’s normal speed when it’s not.
i’ve racked my brain a thousand ways from Sunday, but i still can’t figure out how to calculate that.
also, if you look at the jsfiddle example you’ll see were i was incrementing/de-incrementing based on the direction of the drag. telling which way the slider was going works but the incrementing/de-incrementing based on that was always off…………..
Zero,
They didn’t set you an easy task but fortunately this is the sort of thing I really enjoy solving. It took me the best part of a day, and I work quite quickly.
Here’s my test page complete with CSS, HTML and javascript – all three are modified versions of your original :
DEMO
You will see that I implemented the “sluggish zone” from your design brief AND my orange secondary slider, which is slightly different from my original concept (the arithmetic and variable scoping got rather intense). To run without the orange slider,
#slider2, simply style it withdisplay:nonein the style sheet. The javascript doesn’t need to be changed. You can reveal Mr Orange one day when the designers realise they made a blooper.I haven’t got time to describe in detail how it works, but there are plenty of comments in the code.
Look below the
LINEARnamespace towards the bottom of the script for instructions on how to control the position and sensitivity of the “sluggish zone”.Let me know if you need me to explain anything else.