-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.skroller.min.js
1 lines (1 loc) · 3.75 KB
/
jquery.skroller.min.js
1
(function(e){e.fn.skroller=function(t){function n(t,n){function B(){if(N>i){I();q();R();U();W();X();V()}}function j(){S.css({position:"absolute",top:0,left:0,width:C-y*2});S.css("width","-="+g);N=S.height();P=N-i+y*2;if(P<0)P=0}function F(){e(t).wrap('<div class="'+w+'" id="'+T+'"></div>');k=e("#"+T);k.css({display:"inline-block",height:i,width:C,overflow:"hidden",position:"relative"});e(t).wrap('<div class="sk_mask"></div>');mask=e("#"+T+" .sk_mask");mask.css({position:"absolute",display:"inline-block",top:y,bottom:y,right:y,left:y,overflow:"hidden"})}function I(){H=true;k.append('<div class="sk_rail"></div>');L=e("#"+T+" .sk_rail");m=p==true?0:m;L.css({display:"inline-block",position:"absolute",top:y,right:y,bottom:y,width:o,"background-color":v,"border-radius":M,opacity:m})}function q(){k.append('<div class="scrollbar"></div>');A=e("#"+T+" .scrollbar");O=i-P;if(O<=f)O=f;A.css({display:"inline-block",position:"absolute",top:y,right:y,height:O,width:o,"background-color":u,"border-radius":M,opacity:a})}function R(){_=P/(i-y*2-O);if(_<1)_=1}function U(){A.on("mousedown",function(t){t.preventDefault();var n=t.pageY;var r=parseInt(A.css("top"));e(document).on("mousemove",function(e){mouse_state="down";var t=e.pageY+r;var s=t-n;if(s>=i-O-y)s=i-O-y;if(s<=y)s=y;var o=0-(s-y)*_;A.css("top",s);S.css("top",o)});e(document).on("mouseup",function(t){mouse_state="up";e(document).off("mousemove")})})}function z(){setInterval(function(e){N=S.height();var t=N-i+y*2;if(t<0)t=0;if(t!=P){if(H==false){B()}P=t;O=i-P;if(O<=f)O=f;if(c)A.css("height",O);else A.animate({height:O},"fast");R()}},250)}function W(){if(c==true){A.hide();if(d)L.hide();k.on("mouseenter",function(e){on_frame=true;A.clearQueue();A.fadeIn("fast");if(d){L.clearQueue();L.fadeIn("fast")}});k.on("mouseleave",function(e){on_frame=false;if(mouse_state=="up"){A.clearQueue();A.delay(delay).fadeOut("fast");if(d){L.clearQueue();L.delay(delay).fadeOut("fast")}}});e(document).on("mouseup",function(e){if(on_frame==false){A.clearQueue();A.delay(delay).fadeOut("fast");if(d){L.clearQueue();L.delay(delay).fadeOut("fast")}}})}}function X(){t=document.getElementById(T);var e;t.onwheel=function(t){if(e>Math.abs(t.deltaY)||!e){e=Math.abs(t.deltaY)}var n=t.deltaY/e;var r=S.css("font-size");var s=Math.floor(parseInt(r)*1.5);if(n<0)n=0-s*E;if(n>0)n=s*E;var o=parseInt(S.css("top"));var u=o-n;var a=(u-u*2)/_+y;if(u>0)u=0;if(Math.abs(u)>P)u=0-P;if(a<y)a=y;if(a>i-y-O)a=i-y-O;S.css("top",u);A.css("top",a);if(t.stopPropagation)t.stopPropagation();t.cancelBubble=true;if(t.preventDefault)t.preventDefault();t.returnValue=false};t.onmousewheel=function(e){if(!e)e=window.event;e.deltaY=-e.wheelDelta;t.onwheel(e)}}function V(){L.on("click",function(e){var t=L.offset();var n=e.pageY-t.top;var r=n-O/2;if(r>=i-O-y)r=i-O-y;if(r<=y)r=y;var s=0-(r-y)*_;A.css("top",r);S.css("top",s)})}var n=n||{};var i=n.height||200;var s=n.maxHeight||false;var o=n.barWidth||10;var u=n.barColor||"#2C96DE";var a=n.barOpacity||1;var f=n.barMinHeight||20;var l=n.barMaxHeight||i;var c=n.barHide||false;var h=n.barHideDelay||.5;var p=n.railOff||false;var d=n.railHide||c;var v=n.railColor||u;var m=n.railOpacity||a/5;var g=n.indent||o+o/2;var y=n.padding||0;var b=n.style||"smooth";var w=n.frameClass||"skroller";var E=n.wheelSpeed||1;if(n.indent===0)g=0;if(n.padding===0)y=0;var S=e(t);var x=e(t).attr("id")||r();var T="sk_"+x;var N,C,k,L,A,O,M,_,D,P,H;e(window).load(function(n){N=e(t).height();C=e(t).width();H=false;var r=h*1e3;if(s){if(N<=s)i=N}var u="up";switch(b){case"square":M=0;break;case"round":M=o/2;break;case"smooth":M=o/2/2;break;default:M=b;break}F();j();B();z()})}function r(){var e="";var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(var n=0;n<5;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}this.each(function(e){n(this,t)})}})(jQuery)