How to make speed of scrolling more slower in this jQuery scrolling script?
Posted
by
Jitendra Vyas
on Stack Overflow
See other posts from Stack Overflow
or by Jitendra Vyas
Published on 2011-01-14T04:14:11Z
Indexed on
2011/01/14
6:53 UTC
Read the original article
Hit count: 310
Currently in example speed
and step
both are are 1
. but i need much slower speed of scrolling. How to get full control over speed.
I want the clouds to move much slower
Example
Code
(function($) {
$.fn.scrollingBackground = function(options) {
// settings and defaults.
var settings = options || {};
var speed = settings.speed || 1;
var step = settings.step || 1;
var direction = settings.direction || 'rtl';
var animStep;
// build up a string to pass to animate:
if (direction === 'rtl') {
animStep = "-=" + step + "px";
}
else if (direction === 'ltr') {
animStep = '+=' + step + "px";
}
var element = this;
// perform the animation forever:
var animate = function() {
element.animate({
backgroundPosition: animStep + " 0px"
}, speed, animate);
};
animate();
};
})(jQuery);
$("#header").scrollingBackground({
speed: 1,
step: 1,
direction: 'ltr'
});
$("#header-2").scrollingBackground({
speed: 1,
step: 1,
direction: 'rtl'
});
© Stack Overflow or respective owner