mirror of
https://github.com/wahyd4/cdnjs.git
synced 2026-08-26 05:05:59 +10:00
Add nanoScroller a jquery plugin for scrollbars.
Nanoscroller is a jQuery plugin that offers a simplistic way of implementing Lion OS scrollbars. Homepage: http://jamesflorentino.github.com/nanoScrollerJS/ Github Repository: https://github.com/jamesflorentino/nanoScrollerJS Maintainers: https://github.com/jamesflorentino/ https://github.com/kristerkari/
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
(function(e,j,k){var m,f,l,n,o,p;o={paneClass:"pane",sliderClass:"slider",sliderMinHeight:20,contentClass:"content",iOSNativeScrolling:!1,preventPageScrolling:!1,disableResize:!1,alwaysVisible:!1,flashDelay:1500};m="Microsoft Internet Explorer"===j.navigator.appName&&/msie 7./i.test(j.navigator.appVersion)&&j.ActiveXObject;f=null;l={};p=function(){var c,a;c=k.createElement("div");a=c.style;a.position="absolute";a.width="100px";a.height="100px";a.overflow="scroll";a.top="-9999px";k.body.appendChild(c);
|
||||
a=c.offsetWidth-c.clientWidth;k.body.removeChild(c);return a};n=function(){function c(a,b){this.options=b;f||(f=p());this.el=e(a);this.doc=e(k);this.win=e(j);this.generate();this.createEvents();this.addEvents();this.reset()}c.prototype.preventScrolling=function(a,b){this.isActive&&("DOMMouseScroll"===a.type?("down"===b&&0<a.originalEvent.detail||"up"===b&&0>a.originalEvent.detail)&&a.preventDefault():"mousewheel"===a.type&&a.originalEvent&&a.originalEvent.wheelDelta&&("down"===b&&0>a.originalEvent.wheelDelta||
|
||||
"up"===b&&0<a.originalEvent.wheelDelta)&&a.preventDefault())};c.prototype.updateScrollValues=function(){var a;a=this.content[0];this.maxScrollTop=a.scrollHeight-a.clientHeight;this.contentScrollTop=a.scrollTop;this.maxSliderTop=this.paneHeight-this.sliderHeight;this.sliderTop=this.contentScrollTop*this.maxSliderTop/this.maxScrollTop};c.prototype.handleKeyPress=function(a){var b;if(38===a||33===a||40===a||34===a)b=38===a||40===a?40:0.9*this.paneHeight,b=100*(b/(this.contentHeight-this.paneHeight)),
|
||||
b=b*this.maxSliderTop/100,this.sliderY=38===a||33===a?this.sliderY-b:this.sliderY+b,this.scroll();else if(36===a||35===a)this.sliderY=36===a?0:this.maxSliderTop,this.scroll()};c.prototype.createEvents=function(){var a=this;this.events={down:function(b){a.isBeingDragged=!0;a.offsetY=b.pageY-a.slider.offset().top;a.pane.addClass("active");a.doc.bind("mousemove",a.events.drag).bind("mouseup",a.events.up);return!1},drag:function(b){a.sliderY=b.pageY-a.el.offset().top-a.offsetY;a.scroll();a.updateScrollValues();
|
||||
a.contentScrollTop>=a.maxScrollTop?a.el.trigger("scrollend"):0===a.contentScrollTop&&a.el.trigger("scrolltop");return!1},up:function(){a.isBeingDragged=!1;a.pane.removeClass("active");a.doc.unbind("mousemove",a.events.drag).unbind("mouseup",a.events.up);return!1},resize:function(){a.reset()},panedown:function(b){a.sliderY=(b.offsetY||b.originalEvent.layerY)-0.5*a.sliderHeight;a.scroll();a.events.down(b);return!1},scroll:function(b){a.isBeingDragged||(a.updateScrollValues(),a.sliderY=a.sliderTop,a.slider.css({top:a.sliderTop}),
|
||||
null!=b&&(a.contentScrollTop>=a.maxScrollTop?(a.options.preventPageScrolling&&a.preventScrolling(b,"down"),a.el.trigger("scrollend")):0===a.contentScrollTop&&(a.options.preventPageScrolling&&a.preventScrolling(b,"up"),a.el.trigger("scrolltop"))))},wheel:function(b){if(null!=b)return a.sliderY+=-b.wheelDeltaY||-b.delta,a.scroll(),!1},keydown:function(b){var c;if(null!=b&&(c=b.which,38===c||33===c||40===c||34===c||36===c||35===c))a.sliderY=isNaN(a.sliderY)?0:a.sliderY,l[c]=setTimeout(function(){a.handleKeyPress(c)},
|
||||
100),b.preventDefault()},keyup:function(b){null!=b&&(b=b.which,a.handleKeyPress(b),null!=l[b]&&clearTimeout(l[b]))}}};c.prototype.addEvents=function(){var a;a=this.events;this.options.disableResize||this.win.bind("resize",a.resize);this.slider.bind("mousedown",a.down);this.pane.bind("mousedown",a.panedown).bind("mousewheel DOMMouseScroll",a.wheel);this.content.bind("scroll mousewheel DOMMouseScroll touchmove",a.scroll).bind("keydown",a.keydown).bind("keyup",a.keyup)};c.prototype.removeEvents=function(){var a;
|
||||
a=this.events;this.options.disableResize||this.win.unbind("resize",a.resize);this.slider.unbind("mousedown",a.down);this.pane.unbind("mousedown",a.panedown).unbind("mousewheel DOMMouseScroll",a.wheel);this.content.unbind("scroll mousewheel DOMMouseScroll touchmove",a.scroll).unbind("keydown",a.keydown).unbind("keyup",a.keyup)};c.prototype.generate=function(){var a,b,c,i,d;c=this.options;i=c.paneClass;d=c.sliderClass;a=c.contentClass;this.el.append('<div class="'+i+'"><div class="'+d+'" /></div>');
|
||||
this.content=this.el.children("."+a);this.content.attr("tabindex",0);this.slider=this.el.find("."+d);this.pane=this.el.find("."+i);f&&(b={right:-f},this.el.addClass("has-scrollbar"));c.iOSNativeScrolling&&(null==b&&(b={}),b.WebkitOverflowScrolling="touch");null!=b&&this.content.css(b);c.alwaysVisible&&this.pane.css({opacity:1,visibility:"visible"});return this};c.prototype.restore=function(){this.stopped=!1;this.pane.show();return this.addEvents()};c.prototype.reset=function(){var a,b,c,i,d,e,g;this.el.find("."+
|
||||
this.options.paneClass).length||this.generate().stop();this.stopped&&this.restore();a=this.content[0];c=a.style;i=c.overflowY;m&&this.content.css({height:this.content.height()});b=a.scrollHeight+f;e=this.pane.outerHeight();g=parseInt(this.pane.css("top"),10);d=parseInt(this.pane.css("bottom"),10);d=e+g+d;g=Math.round(d/b*d);g=g>this.options.sliderMinHeight?g:this.options.sliderMinHeight;"scroll"===i&&"scroll"!==c.overflowX&&(g+=f);this.maxSliderTop=d-g;this.contentHeight=b;this.paneHeight=e;this.paneOuterHeight=
|
||||
d;this.sliderHeight=g;this.slider.height(g);this.events.scroll();this.pane.show();this.pane.outerHeight(!0)>=a.scrollHeight&&"scroll"!==i?this.pane.hide():this.el.height()===a.scrollHeight&&"scroll"===i?this.slider.hide():this.slider.show();this.isActive=this.pane.is(":visible");return this};c.prototype.scroll=function(){this.sliderY=Math.max(0,this.sliderY);this.sliderY=Math.min(this.maxSliderTop,this.sliderY);this.content.scrollTop(-1*((this.paneHeight-this.contentHeight+f)*this.sliderY/this.maxSliderTop));
|
||||
this.slider.css({top:this.sliderY});return this};c.prototype.scrollBottom=function(a){this.reset();this.content.scrollTop(this.contentHeight-this.content.height()-a).trigger("mousewheel");return this};c.prototype.scrollTop=function(a){this.reset();this.content.scrollTop(+a).trigger("mousewheel");return this};c.prototype.scrollTo=function(a){this.reset();a=e(a).offset().top;a>this.maxSliderTop&&(a/=this.contentHeight,this.sliderY=a*=this.maxSliderTop,this.scroll());return this};c.prototype.stop=function(){this.stopped=
|
||||
!0;this.removeEvents();this.pane.hide();return this};c.prototype.flash=function(){var a=this;this.pane.addClass("flashed");setTimeout(function(){a.pane.removeClass("flashed")},this.options.flashDelay);return this};return c}();e.fn.nanoScroller=function(c){var a,b,f,i,d,j,g;null!=c&&(i=c.scrollBottom,j=c.scrollTop,d=c.scrollTo,f=c.scroll,g=c.stop,a=c.flash);b=e.extend({},o,c);this.each(function(){var h;if(h=e.data(this,"scrollbar"))e.extend(h.options,c);else{h=new n(this,b);e.data(this,"scrollbar",
|
||||
h)}return i?h.scrollBottom(i):j?h.scrollTop(j):d?h.scrollTo(d):f==="bottom"?h.scrollBottom(0):f==="top"?h.scrollTop(0):f instanceof e?h.scrollTo(f):g?h.stop():a?h.flash():h.reset()})}})(jQuery,window,document);
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "jquery.nanoscroller",
|
||||
"filename": "jquery.nanoscroller.min.js",
|
||||
"version": "0.6.8",
|
||||
"description": "A jQuery plugin that offers a simplistic way of implementing Lion OS scrollbars",
|
||||
"homepage": "http://jamesflorentino.github.com/nanoScrollerJS/",
|
||||
"keywords": [
|
||||
"scrollbar",
|
||||
"custom",
|
||||
"lion",
|
||||
"jquery"
|
||||
],
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "James Florentino",
|
||||
"web": "http://jamesflorentino.com"
|
||||
},{
|
||||
"name": "Krister Kari",
|
||||
"web": "http://krister.fi/"
|
||||
}
|
||||
|
||||
],
|
||||
"repositories": [
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/jamesflorentino/nanoScrollerJS"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user