jQuery UI Slider - Animation of handle and scroll content not in sync
Posted
by
Mayko
on Stack Overflow
See other posts from Stack Overflow
or by Mayko
Published on 2011-11-20T21:52:23Z
Indexed on
2011/11/21
1:50 UTC
Read the original article
Hit count: 448
Im having troubles getting the jQuery UI Slider customized for my purposes.
On load the slider and its content should automatically animate to a certain position. Ideally it should animate to the very right, then stop and then animate back (as a loop) as long as the user doesn't hovers over scroll content or slider.
Following my default slider setup (http://jsfiddle.net/mayko/j6WuE/1/):
var scrollbar = $("#slider").slider({
animate: 3000,
min: 0,
max: $("#timeline_content .items").width(),
change: handleSlider,
slide: handleSlider
});
function handleSlider(e, ui) {
$("#timeline_content").stop().animate({scrollLeft: ui.value}, scrollbar.slider("option", "animate"));
}
If i now try to set the value like this:
$('#slider').slider({'value': 1000});
The scroll content nicely animates, but the handle just jumps to that new position.
Even if I click on the slider track itself the animation of scroll content and slider handle are not in sync.
Does anyone got a solution?
© Stack Overflow or respective owner