Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merged in changes from coeamyd/master. Closes #33 and closes #34

  • Loading branch information...
commit f86cc67b88efff0c6ebc849c34c29b3912edaba6 1 parent 0a109dd
Jonathan Azoff authored
Showing with 23 additions and 9 deletions.
  1. +4 −4 README.md
  2. +2 −2 jquery.overscroll.js
  3. +17 −3 jquery.overscroll.min.js
8 README.md
View
@@ -1,6 +1,6 @@
-Overscroll v1.5.1.1
-===================
-Wednesday, December 7th 2011
+Overscroll v1.5.2
+=================
+Sunday, December 11th 2011
Overscroll is a jQuery Plugin that emulates the iPhone scrolling experience in a browser. It is intended for use with the latest version of jQuery
<http://code.jquery.com/jquery-latest.js>
@@ -77,7 +77,7 @@ As of 1.4.4 you can call the `overscroll` constructor on a jQuery element as muc
Change Log
----------
- * __1.5.1.1__
+ * __1.5.2__
- Added zIndex option for configuring thumb elements' z-index
+ <https://github.com/azoff/Overscroll/issues/33>
- Added handling of external scroll event for repositioning thumbs
4 jquery.overscroll.js
View
@@ -1,5 +1,5 @@
/**@license
- * Overscroll v1.5.1.1
+ * Overscroll v1.5.2
* A jQuery Plugin that emulates the iPhone scrolling experience in a browser.
* http://azoffdesign.com/overscroll
*
@@ -13,7 +13,7 @@
* For API documentation, see the README file
* http://azof.fr/pYCzuM
*
- * Date: Wednesday, December 7th 2011
+ * Date: Sunday, December 11th 2011
*/
/*jslint onevar: true, strict: true */
20 jquery.overscroll.min.js
View
@@ -1,6 +1,6 @@
/*
- Overscroll v1.5.1.1
+ Overscroll v1.5.2
A jQuery Plugin that emulates the iPhone scrolling experience in a browser.
http://azoffdesign.com/overscroll
@@ -14,6 +14,20 @@
For API documentation, see the README file
http://azof.fr/pYCzuM
- Date: Wednesday, December 7th 2011
+ Date: Sunday, December 11th 2011
*/
-(function(a,b,c,d,e){"use strict";e="ontouchstart"in a;d=c.fn.overscroll=function(a){a=a||{};return this.each(function(){d.init(c(this),a)})};c.fn.removeOverscroll=function(a){return this.each(function(){var a=c(this).data(d.removerKey);if(c.isFunction(a)){a()}})};c.extend(d,{events:{wheel:"mousewheel DOMMouseScroll",start:"mousedown",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:.7},init:function(a,f){var g={sizing:d.getSizing(a),cursors:d.getCursors(),flags:{},cleaned:{}};g.options=f=c.extend({showThumbs:true,persistThumbs:false,wheelDirection:"vertical",wheelDelta:d.constants.wheelDelta,scrollDelta:d.constants.scrollDelta,direction:"multi",cancelOn:"",zIndex:999},f);if(f.direction!=="multi"&&f.direction!==f.wheelDirection){f.wheelDirection=f.direction}f.scrollDelta=b.abs(f.scrollDelta);f.wheelDelta=b.abs(f.wheelDelta);a.removeOverscroll();a.data(d.removerKey,d.remover(a,g));if(e){a.css({overflow:"auto","-webkit-overflow-scrolling":"touch","-moz-overflow-scrolling":"touch","overflow-scrolling":"touch"})}else{g.target=a.css({position:"relative",overflow:"hidden",cursor:g.cursors.grab}).on(d.events.wheel,g,d.wheel).on(d.events.start,g,d.start).on(d.events.end,g,d.stop).on(d.events.scroll,g,d.scroll).on(d.events.ignored,false);if(f.showThumbs){g.thumbs={};if(g.sizing.container.scrollWidth>0&&f.direction!=="vertical"){g.thumbs.horizontal=c(d.div).css(d.getThumbCss(g.sizing.thumbs.horizontal,g.options.zIndex)).css({opacity:f.persistThumbs?d.constants.thumbOpacity:0});a.prepend(g.thumbs.horizontal)}if(g.sizing.container.scrollHeight>0&&f.direction!=="horizontal"){g.thumbs.vertical=c(d.div).css(d.getThumbCss(g.sizing.thumbs.vertical,g.options.zIndex)).css({opacity:f.persistThumbs?d.constants.thumbOpacity:0});a.prepend(g.thumbs.vertical)}}}if(f.scrollLeft){a.scrollLeft(f.scrollLeft)}if(f.scrollTop){a.scrollTop(f.scrollTop)}d.moveThumbs(g,a.scrollLeft(),a.scrollTop())},getCursors:function(){var a={};if(c.browser.mozilla){a.grab="-moz-grab";a.grabbing="-moz-grabbing"}else if(c.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(d.removerKey).off(d.events.wheel,d.wheel).off(d.events.start,d.start).off(d.events.end,d.stop).off(d.events.ignored,false);if(b.thumbs){if(b.thumbs.horizontal){b.thumbs.horizontal.remove()}if(b.thumbs.vertical){b.thumbs.vertical.remove()}}}},triggerEvent:function(a,b){b.target.trigger("overscroll:"+a)},toggleThumbs:function(a,b){if(a.thumbs&&!a.options.persistThumbs){if(b){if(a.thumbs.vertical){a.thumbs.vertical.stop(true,true).fadeTo("fast",d.constants.thumbOpacity)}if(a.thumbs.horizontal){a.thumbs.horizontal.stop(true,true).fadeTo("fast",d.constants.thumbOpacity)}}else{if(a.thumbs.vertical){a.thumbs.vertical.fadeTo("fast",0)}if(a.thumbs.horizontal){a.thumbs.horizontal.fadeTo("fast",0)}}}},setPosition:function(a,b,c){b.x=a.pageX;b.y=a.pageY;b.time=d.time();b.index=c;return b},wheel:function(b,c){var e=b.data,f=b.originalEvent;b.preventDefault();d.clearInterval(e.target);if(f.wheelDelta){c=f.wheelDelta/(a.opera?-120:120)}if(f.detail){c=-f.detail/3}if(!e.wheelCapture){e.wheelCapture={timeout:null};d.toggleThumbs(e,true);e.target.stop(true,e.flags.dragging=true)}c*=e.options.wheelDelta;if(e.options.wheelDirection==="horizontal"){this.scrollLeft-=c}else{this.scrollTop-=c}d.moveThumbs(e,this.scrollLeft,this.scrollTop);if(e.wheelCapture.timeout){a.clearTimeout(e.wheelCapture.timeout)}e.wheelCapture.timeout=a.setTimeout(function(a){d.toggleThumbs(e,e.wheelCapture=e.flags.dragging=null)},d.constants.timeout)},moveThumbs:function(a,b,c){var d,e,f,g;if(a.options.showThumbs){d=a.thumbs;e=a.sizing;if(d.horizontal){f=b*(1+e.container.width/e.container.scrollWidth);g=c+e.thumbs.horizontal.top;d.horizontal.css("margin",g+"px 0 0 "+f+"px")}if(d.vertical){f=b+e.thumbs.vertical.left;g=c*(1+e.container.height/e.container.scrollHeight);d.vertical.css("margin",g+"px 0 0 "+f+"px")}}},start:function(a){var b=a.data,e=b.target,f=b.flags;d.clearInterval(b.target);b.startTarget=c(a.target);if(!b.startTarget.is(b.options.cancelOn)){a.preventDefault();b.target.css("cursor",b.cursors.grabbing);f.dragging=f.dragged=false;e.bind(d.events.drag,b,d.drag).stop(true,true);b.position=d.setPosition(a,{});b.capture=d.setPosition(a,{},2);d.triggerEvent("dragstart",b)}},drag:function(a){a.preventDefault();var b=a.data,c=b.flags;if(!c.dragged){d.toggleThumbs(b,true)}c.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}d.moveThumbs(b,this.scrollLeft,this.scrollTop);d.setPosition(a,b.position);if(--b.capture.index<=0){c.dragging=true;d.setPosition(a,b.capture,d.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(){if(b){c.each(b,function(b,c){a.click(c)})}return false})},stop:function(a){var b=a.data,e=b.target,f=b.flags;e.unbind(d.events.drag,d.drag);if(b.position){d.triggerEvent("dragend",b);if(f.dragging){d.drift(this,a,function(){d.toggleThumbs(b,f.dragging=false)})}else{d.toggleThumbs(b,false)}if(f.dragged&&c(a.target).is(b.startTarget)){d.deferClick(b.startTarget);b.startTarget=f.dragged=null}b.capture=b.position=undefined}b.target.css("cursor",b.cursors.grab)},scroll:function(a){var b=a.data,c=b.flags;if(!c.dragging){d.moveThumbs(b,this.scrollLeft,this.scrollTop)}},clearInterval:function(b){b=c(b);var d=b.data("overscroll-interval");if(d){a.clearInterval(d)}b.data("overscroll-interval",null)},setInterval:function(a,b){d.clearInterval(a);c(a).data("overscroll-interval",b)},drift:function(b,c,e){var f=c.data,g,h,i,j,k=b.scrollLeft,l=b.scrollTop,m=d.constants.driftDecay;if(d.time()-f.capture.time>d.constants.driftTimeout){return e.call(null,f)}g=f.options.scrollDelta*(c.pageX-f.capture.x);h=f.options.scrollDelta*(c.pageY-f.capture.y);i=g/d.constants.driftSequences;j=h/d.constants.driftSequences;if(f.options.direction!=="vertical"){k-=g}if(f.options.direction!=="horizontal"){l-=h}d.triggerEvent("driftstart",c.data);d.setInterval(b,a.setInterval(function(){var a=true,c=1,g=-1;if(j>c&&b.scrollTop>l||j<g&&b.scrollTop<l){a=false;b.scrollTop-=j;j/=m}if(i>c&&b.scrollLeft>k||i<g&&b.scrollLeft<k){a=false;b.scrollLeft-=i;i/=m}d.moveThumbs(f,b.scrollLeft,b.scrollTop);if(a){d.clearInterval(b);d.triggerEvent("driftend",f);e.call(null,f)}},d.constants.driftFrequency))},getSizing:function(a){var b={},c=a.get(0);a=b.container={width:a.width(),height:a.height()};a.scrollWidth=a.width>=c.scrollWidth?a.width:c.scrollWidth;a.scrollHeight=a.height>=c.scrollHeight?a.height:c.scrollHeight;b.thumbs={horizontal:{width:a.width*a.width/a.scrollWidth,height:d.constants.thumbThickness,corner:d.constants.thumbThickness/2,left:0,top:a.height-d.constants.thumbThickness},vertical:{width:d.constants.thumbThickness,height:a.height*a.height/a.scrollHeight,corner:d.constants.thumbThickness/2,left:a.width-d.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(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",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,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)}}}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()}}},triggerEvent:function(a,b){b.target.trigger("overscroll:"+a)},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;b.target.unbind(c.events.drag,c.drag);if(b.position){c.triggerEvent("dragend",b);d.dragging?c.drift(this,a,function(){c.toggleThumbs(b,d.dragging=false)}):c.toggleThumbs(b,false);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);
Please sign in to comment.
Something went wrong with that request. Please try again.