Add y-axis scroll function.

This commit is contained in:
Hyunje Alex Jun
2012-11-08 21:46:43 +09:00
parent ca22fedf65
commit efe6727e5d
4 changed files with 104 additions and 6 deletions

1
min/perfect-scrollbar.min.css vendored Normal file
View File

@@ -0,0 +1 @@
.ps-container .ps-scrollbar-y{position:absolute;width:10px;right:5px;background-color:gray}.ps-container .ps-scrollbar-y:hover{background-color:#000;cursor:default}.ps-container .ps-scrollbar-y.in-scrolling{background-color:#000}

View File

@@ -1,3 +1,3 @@
/* Copyright (c) 2012 HyeonJe Jun (http://github.com/noraesae)
* Licensed under the MIT License
*/(function(e){e.fn.perfectScrollbar=function(){e(this).mousewheel(function(t,n,r,i){e(this).scrollTop(e(this).scrollTop()-i*10),e(this).scrollLeft(e(this).scrollLeft()+r*10),t.preventDefault()})}})(jQuery);
*/(function(e){e.fn.perfectScrollbar=function(){var t=e(this),n=e(this).children(),r=e("<div class='ps-scrollbar-y'></div>").appendTo(t),i,s,o,u;t.addClass("ps-container");var a=function(){t.scrollTop(parseInt(u*s/i))},f=function(){i=t.height(),s=n.height(),o=parseInt(i*i/s),u=parseInt(t.scrollTop()*i/s),r.css({top:u+t.scrollTop(),height:o})},l=function(e,n){var s=e+n,a=i-o;s<0?u=0:s>a?u=a:u=s,r.css({top:u+t.scrollTop()})},c=function(){var t,n;r.bind("mousedown.perfect-scroll",function(e){n=e.pageY,t=r.position().top,r.addClass("in-scrolling"),e.stopPropagation(),e.preventDefault()}),e(window).bind("mousemove.perfect-scroll",function(e){r.hasClass("in-scrolling")&&(l(t,e.pageY-n),a(),e.stopPropagation(),e.preventDefault())}),e(window).bind("mouseup.perfect-scroll",function(e){r.hasClass("in-scrolling")&&r.removeClass("in-scrolling")})},h=function(){t.mousewheel(function(e,n,r,i){t.scrollTop(t.scrollTop()-i*10),t.scrollLeft(t.scrollLeft()+r*10),f(),e.preventDefault()})};return f(),c(),t.mousewheel&&h(),t}})(jQuery);