Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. /**
  2. * Handles auto scrolling the expansion content.
  3. * @param index The index to scroll
  4. */
  5. var autoScroll = function() {
  6. function e() {
  7. "number" == typeof l && clearTimeout(l), l = setTimeout(function() {
  8. autoScroll.aScrolls[autoScroll.getIndex(index)] === !0 && t(i, "bottom")
  9. }, 5e3)
  10. }
  11.  
  12. function t(r, c, a) {
  13. if (0 === r.clientHeight) return void window.addEventListener("load", function() {
  14. t(r, c, a)
  15. });
  16. var s = r,
  17. u = s.scrollHeight - s.clientHeight;
  18. switch (
  19. a = "boolean" == typeof a ? a : !1,
  20. "number" == typeof l && clearTimeout(l),
  21. s.removeEventListener("scroll", e),
  22. s.clientHeight == s.scrollHeight && setTimeout(function() {
  23. s.clientHeight != s.scrollHeight && (u = s.scrollHeight - s.clientHeight)
  24. }, 20), c) {
  25. case "bottom":
  26. n = setInterval(function() {
  27. s.scrollTop < u ? s.scrollTop += 1 : (clearInterval(n), n = void 0, setTimeout(function() {
  28. t(i, "top")
  29. }, 500))
  30. }, 80);
  31. break;
  32. case "top":
  33. o = setInterval(function() {
  34. s.scrollTop > 0 ? s.scrollTop -= 5 : (clearInterval(o), o = void 0, a === !0 && setTimeout(function() {
  35. t(i, "bottom")
  36. }, 500))
  37. }, 5);
  38. break;
  39. case "pause":
  40. "number" == typeof n ? (clearInterval(n), e(), s.addEventListener("scroll", e)) : "number" == typeof o && (clearInterval(o), e(), s.addEventListener("scroll", e))
  41. }
  42. }
  43. var n, o, l, i, index;
  44. return {
  45. aScrolls: [],
  46. aScroll: function(index, val){
  47. index = this.getIndex(index);
  48. autoScroll.aScrolls[index] = val;
  49. return autoScroll.aScrolls[index];
  50. },
  51. getIndex: function(index){
  52. switch(index){
  53. case '1-0':
  54. return 0;
  55. break;
  56. case '1-1':
  57. return 1;
  58. break;
  59. case '2-0':
  60. return 2;
  61. break;
  62. case '2-1':
  63. return 3;
  64. break;
  65. default:
  66. break;
  67. }
  68. },
  69. reset: function(index) {
  70. var indexVal = autoScroll.getIndex(index);
  71. i = document.getElementById("isi-scroll-expanded-" + index);
  72. i && t(i, "top")
  73. },
  74. pause: function(index) {
  75. var indexVal = autoScroll.getIndex(index);
  76. i = document.getElementById("isi-scroll-expanded-" + index);
  77. i && t(i, "pause")
  78. },
  79. init: function(index) {
  80. index = index;
  81. var indexVal = autoScroll.getIndex(index);
  82. i = document.getElementById("isi-scroll-expanded-" + index);
  83. t(i, "bottom");
  84. this.aScrolls[indexVal] = 0;
  85.  
  86. "selection" in document && i.addEventListener("selectstart",
  87. function(e) {
  88. e.preventDefault()
  89. }), i.addEventListener("mousedown", function() {
  90. t(i, "pause")
  91. }), i.addEventListener("wheel", function() {
  92. t(i, "pause")
  93. })
  94. }
  95. }
  96. }();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement