Reputation: 4022
What is the equivalent of this:
$('html, body').animate({
scrollTop: 200
}, 400);
In MooTools or agnostic javascript?
Im going round in circles....
Cheers
Upvotes: 1
Views: 1988
Reputation: 8459
Because you asked for a version in mootools, it's just one line:
new Fx.Scroll(window).start(0, 200);
Note: It needs mootools more's Fx.Scroll.
Upvotes: 2
Reputation: 8939
This loop can animate the scrollTop property of the window in basic javascript:
window.onload = function() {
var offset = 0; //vertical offset
var interval = setInterval(function() {
window.scrollTo(0, offset);
offset += 4; // plus 4 pixels
if (offset >= 200) {
clearInterval(interval);
}
}, 8); // 200px/4px==50 cycles ; 400ms/50cycles == 8ms per cycle
};
Upvotes: 2