javascript mootools smooth scroll by 'x' amount of pixels

I am trying to smooth scroll down 180px using javascript/mootools.

I have the following js code:

document.documentElement.scrollTop = document.documentElement.scrollTop + 180;

But how can I for instance make this work over a course of 500ms so it animates the scroll rather than it jumping down (which it does at present).

Cheers, Adi


You can by using Fx.SmoothScroll

var ss = new Fx.SmoothScroll({duration: 500 /* ms */}, window);

$('scroll').addEvent('click', function(){ ss.start(0, 180 /* Y offset of the window */); });


edit: remember to include the plugin (not by default on the core) or include the more bundle

Need Your Help

Window Location Animation

wpf xaml animation

I'm trying to animate my window's location.