Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Handles auto scrolling the expansion content.
- * @param index The index to scroll
- */
- var autoScroll = function() {
- function e() {
- "number" == typeof l && clearTimeout(l), l = setTimeout(function() {
- autoScroll.aScrolls[autoScroll.getIndex(index)] === !0 && t(i, "bottom")
- }, 5e3)
- }
- function t(r, c, a) {
- if (0 === r.clientHeight) return void window.addEventListener("load", function() {
- t(r, c, a)
- });
- var s = r,
- u = s.scrollHeight - s.clientHeight;
- switch (
- a = "boolean" == typeof a ? a : !1,
- "number" == typeof l && clearTimeout(l),
- s.removeEventListener("scroll", e),
- s.clientHeight == s.scrollHeight && setTimeout(function() {
- s.clientHeight != s.scrollHeight && (u = s.scrollHeight - s.clientHeight)
- }, 20), c) {
- case "bottom":
- n = setInterval(function() {
- s.scrollTop < u ? s.scrollTop += 1 : (clearInterval(n), n = void 0, setTimeout(function() {
- t(i, "top")
- }, 500))
- }, 80);
- break;
- case "top":
- o = setInterval(function() {
- s.scrollTop > 0 ? s.scrollTop -= 5 : (clearInterval(o), o = void 0, a === !0 && setTimeout(function() {
- t(i, "bottom")
- }, 500))
- }, 5);
- break;
- case "pause":
- "number" == typeof n ? (clearInterval(n), e(), s.addEventListener("scroll", e)) : "number" == typeof o && (clearInterval(o), e(), s.addEventListener("scroll", e))
- }
- }
- var n, o, l, i, index;
- return {
- aScrolls: [],
- aScroll: function(index, val){
- index = this.getIndex(index);
- autoScroll.aScrolls[index] = val;
- return autoScroll.aScrolls[index];
- },
- getIndex: function(index){
- switch(index){
- case '1-0':
- return 0;
- break;
- case '1-1':
- return 1;
- break;
- case '2-0':
- return 2;
- break;
- case '2-1':
- return 3;
- break;
- default:
- break;
- }
- },
- reset: function(index) {
- var indexVal = autoScroll.getIndex(index);
- i = document.getElementById("isi-scroll-expanded-" + index);
- i && t(i, "top")
- },
- pause: function(index) {
- var indexVal = autoScroll.getIndex(index);
- i = document.getElementById("isi-scroll-expanded-" + index);
- i && t(i, "pause")
- },
- init: function(index) {
- index = index;
- var indexVal = autoScroll.getIndex(index);
- i = document.getElementById("isi-scroll-expanded-" + index);
- t(i, "bottom");
- this.aScrolls[indexVal] = 0;
- "selection" in document && i.addEventListener("selectstart",
- function(e) {
- e.preventDefault()
- }), i.addEventListener("mousedown", function() {
- t(i, "pause")
- }), i.addEventListener("wheel", function() {
- t(i, "pause")
- })
- }
- }
- }();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement