-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrull.min.js
More file actions
13 lines (13 loc) · 2.9 KB
/
Copy pathscrull.min.js
File metadata and controls
13 lines (13 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
/**
* ##### 110110011000011011011000101101011101100010110001001000001101100110000101110110011000011000100000110110001010011111011001100001001101100110000100110110011000011100100000110110011000100000100000110110011000000111011000101010101101100010101101001000001101100110000010110110001011000111011011100011001101100010101000
*
* @name Scrull
* @description Making scroll-bars more attracitve
*
* @author Reiha Hosseini ( @mrReiha ) <iam@reiha.net>
* @version v0.0.4
* @since 07/2015
*
* @license GPL
*/
!function(e,t){"use strict";for(var s,i=i||requestAnimationFrame||mozRequestAnimationFrame||webkitRequestAnimationFrame||msRequestAnimationFrame||function(e){setTimeout(e,62.5)},n=function(e){this.indicator.style.top=100*this.scrollTop/this.height+"%"},l=function(s){var i,l,a,c,o,h,u,m,d,g=!1,p=getComputedStyle(s);~s.className.search(/scrull/gi)||(s.className=s.className?s.className+" scrull":"scrull"),(i=t.createElement("div")).className="inner-scrull",(l=t.createElement("div")).className="scrull-wrapper",(a=t.createElement("div")).className="scruller",(c=t.createElement("div")).className="indicator",a.appendChild(c),(o=s.querySelector(".inner-scrull"))?i.innerHTML=o.innerHTML:i.innerHTML=s.innerHTML,s.innerHTML="",i.appendChild(l),s.appendChild(i),s.appendChild(a),i.indicator=c,i.height=i.offsetHeight,i.itemHeight=s.offsetHeight,m=Math.ceil(100*i.itemHeight/i.height)+Math.ceil(100*r/i.height),m=Math.min(m,100),c.addEventListener("mousedown",(function(e){g=!0,h=e.clientY,u=this.getBoundingClientRect().top-a.getBoundingClientRect().top,s.hasClass("no-selection")||s.addClass("no-selection")}),!1),t.addEventListener("mousemove",(function(e){var t,n,l,a;g&&(n=e.clientY,l=s.getBoundingClientRect(),a=c.getBoundingClientRect(),t=(u+(n-l.top)-(h-l.top))*(i.height-l.height)/(l.height-a.height),i.scrollTop=t)}),!1),e.addEventListener("mouseup",(function(e){g=!1,~t.body.className.search(/no\-selection/gi)&&(t.body.className=t.body.className.replace(/\s?no\-selection/gi,""))}),!1),c.style.height=m+"%",m<100&!~s.className.search(/show\-scruller/gi)&&(s.className+=" show-scruller"),100==m&&~s.className.search(/show\-scruller/gi)&&(s.className=s.className.replace(/\s?show\-scruller/gi,"")),"static"==p.position&&(s.className+=" rel"),i.addEventListener("scroll",n,!1),d="ltr"==p.direction,a.style[d?"right":"left"]=0,a.className+=d?" is-ltr":" is-rtl",i.style.width=parseInt(p.width)+r+"px",i.style.height=parseInt(p.height)+r+"px"},a=t.querySelectorAll(".scrull"),c=a.length,r=25;s=a[--c];)l(s);e.addEventListener("resize",(function(e){for(c=a.length;s=a[--c];)l(s)}),!1),e.scrullTo=function(e){var s=function(){var e,t;(c=(new Date-r)/o)>1&&(c=1),e="function"==typeof easeInOut&&easeInOut(c)||ease&&ease.inOutCube&&ease.inOutCube(c)||(t=c,--t*t*t+1),n.scrollTop=l+a*e,c<1&&i(s)},n=this||t.documentElement,l=n.scrollTop,a=(e=Math.min(n.scrollHeight-n.offsetHeight,e))-l,c=0,r=new Date,o=500;i(s)},e.scrullIt=l}(this,document);