Hi, I'm wondering how to rotate an image when jQuery slider value is changed. For example, the degree of image will change on the fly according to the left(0) to right(360) slider variation. I don't know how to pass the slider value to jQuery's rotate() function. Please help me. Thank you all in advance.
+3
A:
$(document).ready(function() {
$('.selector').slider({
slide: function(event, ui) {
$('.image').rotate(ui.value);
}
});
});
Check out the slide event.
Tomas Lycken
2009-05-22 09:31:11
Thanks Thomas, your solution is perfect. However, How can I rotate from center of the image?
Devyn
2009-05-22 09:49:23
Not sure - I haven't used the .rotate() UI, so I'm not too familiar with it. One way might be to have the image in a div, with an offset of half its size (so the div top-left corner is in the center of the image) and rotate the div. I haven't tested it though, it's just a wild idea... ;)
Tomas Lycken
2009-05-22 09:54:29
Thanks, I'll definitely try :)
Devyn
2009-05-22 11:14:53