File: //usr/share/nodejs/turbolinks/src/turbolinks/scroll_manager.js
// Generated by CoffeeScript 1.12.8
(function() {
var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
Turbolinks.ScrollManager = (function() {
function ScrollManager(delegate) {
this.delegate = delegate;
this.onScroll = bind(this.onScroll, this);
this.onScroll = Turbolinks.throttle(this.onScroll);
}
ScrollManager.prototype.start = function() {
if (!this.started) {
addEventListener("scroll", this.onScroll, false);
this.onScroll();
return this.started = true;
}
};
ScrollManager.prototype.stop = function() {
if (this.started) {
removeEventListener("scroll", this.onScroll, false);
return this.started = false;
}
};
ScrollManager.prototype.scrollToElement = function(element) {
return element.scrollIntoView();
};
ScrollManager.prototype.scrollToPosition = function(arg) {
var x, y;
x = arg.x, y = arg.y;
return window.scrollTo(x, y);
};
ScrollManager.prototype.onScroll = function(event) {
return this.updatePosition({
x: window.pageXOffset,
y: window.pageYOffset
});
};
ScrollManager.prototype.updatePosition = function(position) {
var ref;
this.position = position;
return (ref = this.delegate) != null ? ref.scrollPositionChanged(this.position) : void 0;
};
return ScrollManager;
})();
}).call(this);