I have a scrolling image script that I’d like to update the scroll speed of on the fly, using a hover function. I’ve researched and just can’t figure out how to get the variable to update inside of the function without calling the function again. I don’t want it to start over, I’d just like the speed to increase as it is running.
(function ($) {
$(function () { //on DOM ready
var defspeed = 1;
$(".simply-scroll-list").simplyScroll({
speed: defspeed,
});
});
})(jQuery);
$('.fast-forward').hover(function () {
var defspeed = 5;
});
As you can see above, I don’t know how to integrate those two blocks of code properly.
You cannot increase the speed on the fly in a decent way, because the speed is set only once when you initialize the simpleyScroll plugin.
You could reinitialize the plugin but that could have unwanted side effects. jQuery plugins sometimes add extra html to your DOM and reinitializing it would do that multiple times. Multiple event handlers could get attached to the same nodes and all kinds of stuff could go wrong. I do not know if this is the case with this plugin though. Try it 🙂
I myself would just add it to the plugin. I don’t think it would be hard as the plugin is pretty small.