Browse files

added minified version

  • Loading branch information...
1 parent 39779d5 commit 18e5234c567362eaa03b0ec60e37fb39ff30946c Jonathan Azoff committed Dec 25, 2011
Showing with 16 additions and 18 deletions.
  1. +16 −18 jquery.overscroll.min.js
View
34 jquery.overscroll.min.js
@@ -1,6 +1,6 @@
/*
- Overscroll v1.5.2
+ Overscroll v1.6.0
A jQuery Plugin that emulates the iPhone scrolling experience in a browser.
http://azoffdesign.com/overscroll
@@ -14,21 +14,19 @@
For API documentation, see the README file
http://azof.fr/pYCzuM
- Date: Sunday, December 11th 2011
+ Date: Sunday, December 24th 2011
*/
-(function(i,o,f,c,p){p="ontouchstart"in i;c=f.fn.overscroll=function(a){a=a||{};return this.each(function(){c.init(f(this),a)})};f.fn.removeOverscroll=function(){return this.each(function(){var a=f(this).data(c.removerKey);f.isFunction(a)&&a()})};f.extend(c,{events:{wheel:"mousewheel DOMMouseScroll",start:"mousedown",hover:"mouseenter mouseleave",drag:"mousemove",end:"mouseup mouseleave click",scroll:"scroll",ignored:"select dragstart drag"},div:"<div/>",removerKey:"overscroll-remover",constants:{driftFrequency:40,
-driftSequences:22,driftDecay:1.15,driftTimeout:100,timeout:400,captureThreshold:3,wheelDelta:20,scrollDelta:15,thumbThickness:6,thumbOpacity:0.7},init:function(a,b){var d={sizing:c.getSizing(a),cursors:c.getCursors(),flags:{},cleaned:{}};d.options=b=f.extend({showThumbs:true,persistThumbs:false,hoverThumbs:false,wheelDirection:"vertical",wheelDelta:c.constants.wheelDelta,scrollDelta:c.constants.scrollDelta,direction:"multi",cancelOn:"",zIndex:999},b);if(b.direction!=="multi"&&b.direction!==b.wheelDirection)b.wheelDirection=
-b.direction;b.scrollDelta=o.abs(b.scrollDelta);b.wheelDelta=o.abs(b.wheelDelta);a.removeOverscroll();a.data(c.removerKey,c.remover(a,d));if(p)a.css({overflow:"auto","-webkit-overflow-scrolling":"touch","-moz-overflow-scrolling":"touch","overflow-scrolling":"touch"});else{d.target=a.css({position:"relative",overflow:"hidden",cursor:d.cursors.grab}).on(c.events.wheel,d,c.wheel).on(c.events.start,d,c.start).on(c.events.end,d,c.stop).on(c.events.scroll,d,c.scroll).on(c.events.ignored,false);if(b.showThumbs){d.thumbs=
-{};if(d.sizing.container.scrollWidth>0&&b.direction!=="vertical"){d.thumbs.horizontal=f(c.div).css(c.getThumbCss(d.sizing.thumbs.horizontal,d.options.zIndex)).css({opacity:b.persistThumbs?c.constants.thumbOpacity:0});a.prepend(d.thumbs.horizontal)}if(d.sizing.container.scrollHeight>0&&b.direction!=="horizontal"){d.thumbs.vertical=f(c.div).css(c.getThumbCss(d.sizing.thumbs.vertical,d.options.zIndex)).css({opacity:b.persistThumbs?c.constants.thumbOpacity:0});a.prepend(d.thumbs.vertical)}d.options.hoverThumbs&&
-a.on(c.events.hover,d,c.hover)}}b.scrollLeft&&a.scrollLeft(b.scrollLeft);b.scrollTop&&a.scrollTop(b.scrollTop);c.moveThumbs(d,a.scrollLeft(),a.scrollTop())},getCursors:function(){var a={};if(f.browser.mozilla){a.grab="-moz-grab";a.grabbing="-moz-grabbing"}else if(f.browser.webkit){a.grab="-webkit-grab";a.grabbing="-webkit-grabbing"}else a.grab=a.grabbing="move";return a},remover:function(a,b){return function(){a.removeAttr("style").removeData(c.removerKey).off(c.events.wheel,c.wheel).off(c.events.start,
-c.start).off(c.events.end,c.stop).off(c.events.ignored,false);if(b.thumbs){b.thumbs.horizontal&&b.thumbs.horizontal.remove();b.thumbs.vertical&&b.thumbs.vertical.remove();b.options.hoverThumbs&&a.off(c.events.hover,c.hover)}}},triggerEvent:function(a,b){b.target.trigger("overscroll:"+a)},hover:function(a){c.toggleThumbs(a.data,a.type==="mouseenter")},toggleThumbs:function(a,b){if(a.thumbs&&!a.options.persistThumbs)if(b){a.thumbs.vertical&&a.thumbs.vertical.stop(true,true).fadeTo("fast",c.constants.thumbOpacity);
-a.thumbs.horizontal&&a.thumbs.horizontal.stop(true,true).fadeTo("fast",c.constants.thumbOpacity)}else{a.thumbs.vertical&&a.thumbs.vertical.fadeTo("fast",0);a.thumbs.horizontal&&a.thumbs.horizontal.fadeTo("fast",0)}},setPosition:function(a,b,d){b.x=a.pageX;b.y=a.pageY;b.time=c.time();b.index=d;return b},wheel:function(a,b){var d=a.data,e=a.originalEvent;a.preventDefault();c.clearInterval(d.target);if(e.wheelDelta)b=e.wheelDelta/(i.opera?-120:120);if(e.detail)b=-e.detail/3;if(!d.wheelCapture){d.wheelCapture=
-{timeout:null};c.toggleThumbs(d,true);d.target.stop(true,d.flags.dragging=true)}b*=d.options.wheelDelta;if(d.options.wheelDirection==="horizontal")this.scrollLeft-=b;else this.scrollTop-=b;c.moveThumbs(d,this.scrollLeft,this.scrollTop);d.wheelCapture.timeout&&i.clearTimeout(d.wheelCapture.timeout);d.wheelCapture.timeout=i.setTimeout(function(){c.toggleThumbs(d,d.wheelCapture=d.flags.dragging=null)},c.constants.timeout)},moveThumbs:function(a,b,d){var e,g,h;if(a.options.showThumbs){e=a.thumbs;a=a.sizing;
-if(e.horizontal){g=b*(1+a.container.width/a.container.scrollWidth);h=d+a.thumbs.horizontal.top;e.horizontal.css("margin",h+"px 0 0 "+g+"px")}if(e.vertical){g=b+a.thumbs.vertical.left;h=d*(1+a.container.height/a.container.scrollHeight);e.vertical.css("margin",h+"px 0 0 "+g+"px")}}},start:function(a){var b=a.data,d=b.target,e=b.flags;c.clearInterval(b.target);b.startTarget=f(a.target);if(!b.startTarget.is(b.options.cancelOn)){a.preventDefault();b.target.css("cursor",b.cursors.grabbing);e.dragging=e.dragged=
-false;d.bind(c.events.drag,b,c.drag).stop(true,true);b.position=c.setPosition(a,{});b.capture=c.setPosition(a,{},2);c.triggerEvent("dragstart",b)}},drag:function(a){a.preventDefault();var b=a.data,d=b.flags;d.dragged||c.toggleThumbs(b,true);d.dragged=true;if(b.options.direction!=="vertical")this.scrollLeft-=a.pageX-b.position.x;if(b.options.direction!=="horizontal")this.scrollTop-=a.pageY-b.position.y;c.moveThumbs(b,this.scrollLeft,this.scrollTop);c.setPosition(a,b.position);if(--b.capture.index<=
-0){d.dragging=true;c.setPosition(a,b.capture,c.constants.captureThreshold)}},time:function(){return(new Date).getTime()},deferClick:function(a){var b=a.data("events");b=b&&b.click?b.click.slice():false;a.unbind("click").one("mouseup",function(){b&&f.each(b,function(d,e){a.click(e)});return false})},stop:function(a){var b=a.data,d=b.flags,e=function(){if(!b.options.hoverThumbs)c.toggleThumbs(b,d.dragging=false)};b.target.unbind(c.events.drag,c.drag);if(b.position){c.triggerEvent("dragend",b);d.dragging?
-c.drift(this,a,e):e();if(d.dragged&&f(a.target).is(b.startTarget)){c.deferClick(b.startTarget);b.startTarget=d.dragged=null}b.capture=b.position=undefined}b.target.css("cursor",b.cursors.grab)},scroll:function(a){a=a.data;a.flags.dragging||c.moveThumbs(a,this.scrollLeft,this.scrollTop)},clearInterval:function(a){a=f(a);var b=a.data("overscroll-interval");b&&i.clearInterval(b);a.data("overscroll-interval",null)},setInterval:function(a,b){c.clearInterval(a);f(a).data("overscroll-interval",b)},drift:function(a,
-b,d){var e=b.data,g,h,j,k,l=a.scrollLeft,m=a.scrollTop,q=c.constants.driftDecay;if(c.time()-e.capture.time>c.constants.driftTimeout)return d.call(null,e);g=e.options.scrollDelta*(b.pageX-e.capture.x);h=e.options.scrollDelta*(b.pageY-e.capture.y);j=g/c.constants.driftSequences;k=h/c.constants.driftSequences;if(e.options.direction!=="vertical")l-=g;if(e.options.direction!=="horizontal")m-=h;c.triggerEvent("driftstart",b.data);c.setInterval(a,i.setInterval(function(){var n=true;if(k>1&&a.scrollTop>m||
-k<-1&&a.scrollTop<m){n=false;a.scrollTop-=k;k/=q}if(j>1&&a.scrollLeft>l||j<-1&&a.scrollLeft<l){n=false;a.scrollLeft-=j;j/=q}c.moveThumbs(e,a.scrollLeft,a.scrollTop);if(n){c.clearInterval(a);c.triggerEvent("driftend",e);d.call(null,e)}},c.constants.driftFrequency))},getSizing:function(a){var b={},d=a.get(0);a=b.container={width:a.width(),height:a.height()};a.scrollWidth=a.width>=d.scrollWidth?a.width:d.scrollWidth;a.scrollHeight=a.height>=d.scrollHeight?a.height:d.scrollHeight;b.thumbs={horizontal:{width:a.width*
-a.width/a.scrollWidth,height:c.constants.thumbThickness,corner:c.constants.thumbThickness/2,left:0,top:a.height-c.constants.thumbThickness},vertical:{width:c.constants.thumbThickness,height:a.height*a.height/a.scrollHeight,corner:c.constants.thumbThickness/2,left:a.width-c.constants.thumbThickness,top:0}};return b},getThumbCss:function(a,b){return{position:"absolute","background-color":"black",width:a.width+"px",height:a.height+"px",margin:a.top+"px 0 0 "+a.left+"px","-moz-border-radius":a.corner+
-"px","-webkit-border-radius":a.corner+"px","border-radius":a.corner+"px","z-index":b}}})})(window,Math,jQuery);
+(function(m,r,y,H,o,I,k,z){var n=o.mozilla?"-moz-":o.webkit?"-webkit-":o.opera?"-o-":o.msie&&o.version>9?"-ms-":"",A=m.requestAnimationFrame||m.webkitRequestAnimationFrame||m.mozRequestAnimationFrame||m.oRequestAnimationFrame||m.msRequestAnimationFrame||function(b){y(b,1E3/60)},s={cursorGrab:n?n+"grab":"move",cursorGrabbing:n?n+"grabbing":"move",scrollingProp:n?n+"overflow-scrolling":"overflow-scrolling",touchEnabled:"ontouchstart"in m},l={drag:"mousemove",end:"mouseup mouseleave click",hover:"mouseenter mouseleave",
+ignored:"select dragstart drag",scroll:"scroll",start:"mousedown",wheel:"mousewheel DOMMouseScroll"},h={captureThreshold:3,driftDecay:1.1,driftSequences:22,driftTimeout:100,scrollDelta:15,thumbOpacity:0.7,thumbThickness:6,thumbTimeout:400,wheelDelta:20},J={cancelOn:"",direction:"multi",hoverThumbs:false,scrollDelta:h.scrollDelta,showThumbs:true,persistThumbs:false,wheelDelta:h.wheelDelta,wheelDirection:"vertical",zIndex:999},t=function(b,a){a.trigger("overscroll:"+b)},u=function(b,a,c){a.x=b.pageX;
+a.y=b.pageY;a.time=(new Date).getTime();a.index=c;return a},p=function(b,a,c,e){var d,f;if(b&&b.added){if(b.horizontal){d=c*(1+a.container.width/a.container.scrollWidth);f=e+a.thumbs.horizontal.top;b.horizontal.css("margin",f+"px 0 0 "+d+"px")}if(b.vertical){d=c+a.thumbs.vertical.left;f=e*(1+a.container.height/a.container.scrollHeight);b.vertical.css("margin",f+"px 0 0 "+d+"px")}}},q=function(b,a,c){if(b&&b.added&&!a.persistThumbs)if(c){b.vertical&&b.vertical.stop(true,true).fadeTo("fast",h.thumbOpacity);
+b.horizontal&&b.horizontal.stop(true,true).fadeTo("fast",h.thumbOpacity)}else{b.vertical&&b.vertical.fadeTo("fast",0);b.horizontal&&b.horizontal.fadeTo("fast",0)}},K=function(b){var a=b.data("events"),c=a&&a.click?a.click.slice():[];a&&delete a.click;b.one("mouseup",function(){k.each(c,function(e,d){b.click(d)});return false})},L=function(b){var a=b.data;q(a.thumbs,a.options,b.type==="mouseenter")},M=function(b){b=b.data;b.flags.dragged||p(b.thumbs,b.sizing,this.scrollLeft,this.scrollTop)},B=function(b){b.preventDefault();
+var a=b.data,c=a.options,e=a.sizing,d=a.thumbs,f=a.wheel,g=a.flags,i;b=b.originalEvent;g.drifting=false;if(b.wheelDelta)i=b.wheelDelta/(o.opera?-120:120);if(b.detail)i=-b.detail/3;i*=c.wheelDelta;if(!f){g.dragging=true;a.wheel=f={timeout:null};q(d,c,true)}if(c.wheelDirection==="horizontal")this.scrollLeft-=i;else this.scrollTop-=i;f.timeout&&H(f.timeout);p(d,e,this.scrollLeft,this.scrollTop);f.timeout=y(function(){q(d,c,a.wheel=g.dragging=null)},h.thumbTimeout)},C=function(b){b.preventDefault();var a=
+b.data,c=a.options,e=a.sizing,d=a.thumbs,f=a.position,g=a.flags;g.dragged||q(d,c,true);g.dragged=true;if(c.direction!=="vertical")this.scrollLeft-=b.pageX-f.x;if(a.options.direction!=="horizontal")this.scrollTop-=b.pageY-f.y;u(b,a.position);if(--a.capture.index<=0){g.dragging=true;u(b,a.capture,h.captureThreshold)}p(d,e,this.scrollLeft,this.scrollTop)},Q=function(b,a,c){var e=a.data,d,f,g,i=e.capture,j=e.options,N=e.sizing,O=e.thumbs;d=(new Date).getTime()-i.time;var v=b.scrollLeft,w=b.scrollTop,
+D=h.driftDecay;if(d>h.driftTimeout)return c(e);d=j.scrollDelta*(a.pageX-i.x);a=j.scrollDelta*(a.pageY-i.y);if(j.direction!=="vertical")v-=d;if(j.direction!=="horizontal")w-=a;f=d/h.driftSequences;g=a/h.driftSequences;t("driftstart",e.target);e.drifting=true;A(function P(){if(e.drifting){e.drifting=false;if(g>1&&b.scrollTop>w||g<-1&&b.scrollTop<w){e.drifting=true;b.scrollTop-=g;g/=D}if(f>1&&b.scrollLeft>v||f<-1&&b.scrollLeft<v){e.drifting=true;b.scrollLeft-=f;f/=D}p(O,N,b.scrollLeft,b.scrollTop);A(P)}else{t("driftend",
+e.target);c(e)}})},E=function(b){b.preventDefault();var a=b.data,c=a.target,e=a.start=k(b.target),d=a.flags;d.drifting=false;if(!e.is(a.options.cancelOn)){c.css("cursor",s.cursorGrabbing);d.dragging=d.dragged=false;c.on(l.drag,a,C);a.position=u(b,{});a.capture=u(b,{},h.captureThreshold);t("dragstart",c)}},F=function(b){var a=b.data,c=a.target,e=a.options,d=a.flags,f=a.thumbs,g=function(){f&&!e.hoverThumbs&&q(f,e,false)};c.unbind(l.drag,C);if(a.position){t("dragend",c);d.dragging?Q(this,b,g):g()}d.dragging&&
+a.start.is(b.target)&&K(a.start);a.start=a.capture=a.position=d.dragged=d.dragging=false;c.css("cursor",s.cursorGrab)},x=function(b,a){var c=k(b),e,d=c.data("overscroll")||{},f=c.attr("style"),g=a?function(){d=c.data("overscroll");e=d.thumbs;f?c.attr("style",f):c.removeAttr("style");if(e){e.horizontal&&e.horizontal.remove();e.vertical&&e.vertical.remove()}c.removeData("overscroll").off(l.wheel,B).off(l.start,E).off(l.end,F).off(l.ignored,false)}:k.noop;return k.isFunction(d.remover)?d.remover:g},
+G=function(b,a){var c={position:"absolute",opacity:a.persistThumbs?h.thumbOpacity:0,"background-color":"black",width:b.width+"px",height:b.height+"px",margin:b.top+"px 0 0 "+b.left+"px","z-index":a.zIndex};c[n+"border-radius"]=b.corner+"px";return c};m=function(b){return this.removeOverscroll().each(function(){var a=this,c=b,e;c=c;c=k.extend({},J,c);if(c.direction!=="multi"&&c.direction!==c.wheelDirection)c.wheelDirection=c.direction;c.scrollDelta=r.abs(c.scrollDelta);c.wheelDelta=r.abs(c.wheelDelta);
+c.scrollLeft=c.scrollLeft===z?null:r.abs(c.scrollLeft);c.scrollTop=c.scrollTop===z?null:r.abs(c.scrollTop);e=c=c;var d=x(a,true),f=a,g=k(f),i=g.width();g=g.height();var j=i>=f.scrollWidth?i:f.scrollWidth;f=g>=f.scrollHeight?g:f.scrollHeight;d={flags:{dragging:false},options:e,remover:d,sizing:e={container:{width:i,height:g,scrollWidth:j,scrollHeight:f},thumbs:{horizontal:{width:i*i/j,height:h.thumbThickness,corner:h.thumbThickness/2,left:0,top:g-h.thumbThickness},vertical:{width:h.thumbThickness,
+height:g*g/f,corner:h.thumbThickness/2,left:i-h.thumbThickness,top:0}}}};d.target=a=k(a).css({position:"relative",overflow:"hidden",cursor:s.cursorGrab}).on(l.wheel,d,B).on(l.start,d,E).on(l.end,d,F).on(l.scroll,d,M).on(l.ignored,false);c.scrollLeft!==null&&a.scrollLeft(c.scrollLeft);c.scrollTop!==null&&a.scrollTop(c.scrollTop);if(c.showThumbs){i=a;f=c;g={};j=false;if(e.container.scrollWidth>0&&f.direction!=="vertical"){j=G(e.thumbs.horizontal,f);g.horizontal=k("<div/>").css(j).prependTo(i)}if(e.container.scrollHeight>
+0&&f.direction!=="horizontal"){j=G(e.thumbs.vertical,f);g.vertical=k("<div/>").css(j).prependTo(i)}g.added=!!j;d.thumbs=g;if(g.added){p(g,e,a.scrollLeft(),a.scrollTop());c.hoverThumbs&&a.on(l.hover,d,L)}}a.data("overscroll",d)})};var R=function(){return this.removeOverscroll().each(function(){k(this).data("overscroll",{remover:x(this)}).css(n+"overflow-scrolling","touch").css("overflow","auto")})};m.settings=h;k.extend(I,{overscroll:s.touchEnabled?R:m,removeOverscroll:function(){return this.each(function(){x(this)()})}})})(window,
+Math,setTimeout,clearTimeout,jQuery.browser,jQuery.fn,jQuery);

0 comments on commit 18e5234

Please sign in to comment.