var Scroll = function ( element, to, time, callback ) {
var hasX = 'x' in to,
hasY = 'y' in to,
x = [], y = [],
from = [ element.scrollTop, element.scrollLeft ],
start = new Date().getTime(),
now, progress;
if ( hasX ) {
x = to.x instanceof Array ? to.x : [ to.x, function ( progress ) {
return progress;
} ];
}
if ( hasY ) {
y = to.y instanceof Array ? to.y : [ to.y, function ( progress ) {
return progress;
} ];
}
setTimeout(function() {
now = (new Date().getTime()) - start;
progress = now / time;
if ( hasX ) {
element.scrollLeft = ( x[0] - from[0] ) * x[1]( progress ) + from[0];
}
if ( hasY ) {
element.scrollTop = ( y[0] - from[0] ) * y[1]( progress ) + from[0];
}
if (progress < 1) {
setTimeout(arguments.callee, 10);
} else {
callback();
}
}, 10);
};