Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var obj = document.getElementById(id);
- if(obj)
- {
- obj.up = false;
- obj.down = false;
- obj.fast = false;
- var container = document.createElement("div");
- var parent = obj.parentNode;
- container.id="easyscroll";
- parent.appendChild(container,obj);
- parent.removeChild(obj);
- container.style.position = "relative";
- container.style.height = height + "px";
- container.style.overflow = "hidden";
- obj.style.position = "absolute";
- obj.style.top = "0";
- obj.style.left = "0";
- container.appendChild(obj);
- var btns = new Array();
- var ul = document.createElement("ul");
- for (var i=0;i<nav.length;i++)
- {
- var li = document.createElement("li");
- li.innerHTML = nav[i];
- li.id = navId[i];
- btns.push(li);
- ul.appendChild(li);
- };
- parent.appendChild(ul,container);
- ul.id="easyscrollnav";
- btns[0].onmouseover = function()
- {
- obj.up = true;
- this.className = "over";
- };
- btns[0].onmouseout = function()
- {
- obj.up = false;
- this.className = "";
- };
- btns[1].onmouseover = function()
- {
- obj.down = true;
- this.className = "over";
- };
- btns[1].onmouseout = function()
- {
- obj.down = false;
- this.className = "";
- };
- btns[0].onmousedown = btns[1].onmousedown = function()
- {
- obj.fast = true;
- };
- btns[0].onmouseup = btns[1].onmouseup = function()
- {
- obj.fast = false;
- };
- btns[2].onmouseover = function()
- {
- this.className = "over";
- };
- btns[2].onmouseout = function()
- {
- this.className = "";
- };
- btns[2].onclick = function()
- {
- obj.style.top = "0px";
- };
- this.start = function()
- {
- var newTop;
- var objHeight = obj.offsetHeight;
- var top = obj.offsetTop;
- var fast = (obj.fast) ? 2 : 1;
- if(obj.down)
- {
- newTop = ((objHeight+top) > height) ? top-(speed*fast) : top;
- obj.style.top = newTop + "px";
- };
- if(obj.up)
- {
- newTop = (top < 0) ? top+(speed*fast) : top;
- obj.style.top = newTop + "px";
- };
- };
- obj.interval = setInterval("start()",50);
- }
Add Comment
Please, Sign In to add comment