Guest User

Untitled

a guest
Jan 21st, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. var obj = document.getElementById(id);
  2. if(obj)
  3. {
  4. obj.up = false;
  5. obj.down = false;
  6. obj.fast = false;
  7.  
  8. var container = document.createElement("div");
  9.  
  10. var parent = obj.parentNode;
  11.  
  12. container.id="easyscroll";
  13.  
  14. parent.appendChild(container,obj);
  15. parent.removeChild(obj);
  16.  
  17. container.style.position = "relative";
  18. container.style.height = height + "px";
  19. container.style.overflow = "hidden";
  20. obj.style.position = "absolute";
  21. obj.style.top = "0";
  22. obj.style.left = "0";
  23. container.appendChild(obj);
  24.  
  25. var btns = new Array();
  26. var ul = document.createElement("ul");
  27.  
  28. for (var i=0;i<nav.length;i++)
  29. {
  30. var li = document.createElement("li");
  31. li.innerHTML = nav[i];
  32. li.id = navId[i];
  33. btns.push(li);
  34. ul.appendChild(li);
  35. };
  36. parent.appendChild(ul,container);
  37. ul.id="easyscrollnav";
  38. btns[0].onmouseover = function()
  39. {
  40. obj.up = true;
  41. this.className = "over";
  42. };
  43. btns[0].onmouseout = function()
  44. {
  45. obj.up = false;
  46. this.className = "";
  47. };
  48. btns[1].onmouseover = function()
  49. {
  50. obj.down = true;
  51. this.className = "over";
  52. };
  53. btns[1].onmouseout = function()
  54. {
  55. obj.down = false;
  56. this.className = "";
  57. };
  58. btns[0].onmousedown = btns[1].onmousedown = function()
  59. {
  60. obj.fast = true;
  61. };
  62. btns[0].onmouseup = btns[1].onmouseup = function()
  63. {
  64. obj.fast = false;
  65. };
  66. btns[2].onmouseover = function()
  67. {
  68. this.className = "over";
  69. };
  70. btns[2].onmouseout = function()
  71. {
  72. this.className = "";
  73. };
  74. btns[2].onclick = function()
  75. {
  76. obj.style.top = "0px";
  77. };
  78.  
  79. this.start = function()
  80. {
  81. var newTop;
  82. var objHeight = obj.offsetHeight;
  83. var top = obj.offsetTop;
  84. var fast = (obj.fast) ? 2 : 1;
  85. if(obj.down)
  86. {
  87. newTop = ((objHeight+top) > height) ? top-(speed*fast) : top;
  88. obj.style.top = newTop + "px";
  89. };
  90. if(obj.up)
  91. {
  92. newTop = (top < 0) ? top+(speed*fast) : top;
  93. obj.style.top = newTop + "px";
  94. };
  95. };
  96. obj.interval = setInterval("start()",50);
  97. }
Add Comment
Please, Sign In to add comment