scrollDocument function hash var self this if hash hash length if hash

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
scrollDocument: function (hash) {
var self = this;
if (hash && hash.length > 0) {
if (hash.substr(0, 1) == '/')
return;
try {
var el = $('#' + hash + ', a[name="' + hash + '"]');
if (el.length > 0) {
var $window = $(window);
var scroller = function () {
$window.scrollTop(el.offset().top);
};
this.scroll_interval = setInterval(scroller, 500);
scroller();
var events = "touchmove.auto_scroller keydown.auto_scroller click.auto_scroller" +
"MozMousePixelScroll.auto_scroller mousewheel.auto_scroller wheel.auto_scroller";
$(window).on(events, function (e) {
console.error(e.originalEvent, "test");
clearInterval(self.scroll_interval);
self.scroll_interval = null;
$(window).off('.auto_scroller');
});
return;
}
} catch (e) { console.error(e); }
}
window.scrollTo(0, 0);
},