Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #61 from azoff/1.6.3

1.6.3 Changes
  • Loading branch information...
commit 2e2a4ad4f7c2c87f1b7dfdb3ec917d5907aac14f 2 parents 72262a7 + 9c18408
Jonathan Azoff authored
Showing with 72 additions and 61 deletions.
  1. +11 −2 README.md
  2. +59 −51 jquery.overscroll.js
  3. +2 −8 jquery.overscroll.min.js
View
13 README.md
@@ -1,6 +1,6 @@
-Overscroll v1.6.2
+Overscroll v1.6.3
=================
-Thursday, April 12th 2012
+Thursday, May 17th 2012
Overscroll is a jQuery Plugin that [polyfills](http://remysharp.com/2010/10/08/what-is-a-polyfill) mobile safari's [overflow-scrolling](http://johanbrook.com/browsers/native-momentum-scrolling-ios-5/) style in a desktop browser. It is intended for use with [the latest version of jQuery](http://code.jquery.com/jquery-latest.js).
@@ -101,8 +101,17 @@ As of 1.3.1, if you would like to add click handlers to links inside of overscro
As of 1.4.4 you can call the `overscroll` constructor on a jQuery element as much as you like, without worrying about memory leaks. What this means is that you may dynamically add elements to the overscrolled element, and then re-call the `overscroll` method to take into account the new height. This would have been done programatically if DOM Elements supported the resize event, alas only the window object supports this event.
+A Note About AMD
+----------------
+Full disclosure, I have no interest in supporting [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD). It seems great, I'm sure lots of people use it - but [its goals](http://requirejs.org/docs/whyamd.html) seem tangential to making Overscroll a better plug-in. It's hard enough keeping up with browsers, no sense in making Overscroll anything more than what it is: a jQuery plug-in. If you want to turn Overscroll into an AMD module, than I wholly encourage you to do so! Just fork the project and shoot me a link so that I can reference it here.
+
Change Log
----------
+ * __1.6.3__
+ - Fixed Chrome 19's bad overflow-scrolling implementation.
+ + <https://github.com/azoff/Overscroll/issues/59>
+ - Only apply overscroll if there is content to scroll. (thanks @tsneed290)
+ + <https://github.com/azoff/Overscroll/issues/57>
* __1.6.2__
- Explicit check for start element.
+ <https://github.com/azoff/Overscroll/issues/48>
View
110 jquery.overscroll.js
@@ -1,5 +1,5 @@
/**
- * Overscroll v1.6.2
+ * Overscroll v1.6.3
* A jQuery Plugin that emulates the iPhone scrolling experience in a browser.
* http://azoffdesign.com/overscroll
*
@@ -13,14 +13,14 @@
* For API documentation, see the README file
* http://azof.fr/pYCzuM
*
- * Date: Thursday, April 12th 2012
+ * Date: Thursday, May 17th 2012
*/
/*jslint onevar: true, strict: true */
/*global window, document, setTimeout, clearTimeout, jQuery */
-(function(global, dom, math, wait, cancel, namespace, $, none){
+(function(global, dom, browser, math, wait, cancel, namespace, $, none){
// We want to run this plug-in in strict-mode
// so that we may benefit from any optimizations
@@ -33,6 +33,7 @@
// runs feature detection for overscroll
compat = (function(){
var b = $.browser, fallback,
+ agent = browser.userAgent,
style = dom.createElement(datakey).style,
prefix = b.webkit ? 'webkit' : (b.mozilla ? 'moz' : (b.msie ? 'ms' : (b.opera ? 'o' : ''))),
cssprefix = prefix ? ['-','-'].join(prefix) : '';
@@ -50,12 +51,13 @@
// check to see if overflowScrolling is available
if (style[scroller] !== none) {
- compat.overflowScrolling = cssprefix + 'overflow-scrolling';
- } else if (compat.touchEvents) {
-
+ // Chrome 19 introduced overflow scrolling. Unfortunately, their touch
+ // implementation is incomplete. Hence, we act like it is not supported
+ // for chrome. #59
+ if (agent.indexOf('Chrome') < 0) {
+ compat.overflowScrolling = cssprefix + 'overflow-scrolling';
+ }
}
-
-
});
// check to see if the client supports touch
@@ -503,9 +505,11 @@
width = $target.width(),
height = $target.height(),
scrollWidth = width >= target.scrollWidth ? width : target.scrollWidth,
- scrollHeight = height >= target.scrollHeight ? height : target.scrollHeight;
+ scrollHeight = height >= target.scrollHeight ? height : target.scrollHeight,
+ hasScroll = scrollWidth > width || scrollHeight > height;
return {
+ valid: hasScroll,
container: {
width: width,
height: height,
@@ -614,55 +618,59 @@
// This function takes a jQuery element, some
// (optional) options, and sets up event metadata
// for each instance the plug-in affects
- setup = function(target, options) {
+ setup = function(target, options) {
// create initial data properties for this instance
- var thumbs, sizing,
- data = {
- flags: { dragging: false },
- options: options = getOptions(options),
- remover: getRemover(target, true),
- sizing: sizing = getSizing(target)
+ options = getOptions(options);
+ var sizing = getSizing(target),
+ thumbs, data = {
+ options: options, sizing: sizing,
+ flags: { dragging: false },
+ remover: getRemover(target, true)
};
+
+ // only apply handlers if the overscrolled element
+ // actually has an area to scroll
+ if (sizing.valid) {
+ // provide a circular-reference, enable events, and
+ // apply any required CSS
+ data.target = target = $(target).css({
+ position: 'relative',
+ overflow: 'hidden',
+ cursor: compat.cursorGrab
+ }).on(events.wheel, data, wheel)
+ .on(events.start, data, start)
+ .on(events.end, data, stop)
+ .on(events.scroll, data, scroll)
+ .on(events.ignored, false);
+
+ // apply the stop listeners for drag end
+ if(options.dragHold) {
+ $(document).on(events.end, data, stop);
+ } else {
+ data.target.on(events.end, data, stop);
+ }
- // provide a circular-reference, enable events, and
- // apply any required CSS
- data.target = target = $(target).css({
- position: 'relative',
- overflow: 'hidden',
- cursor: compat.cursorGrab
- }).on(events.wheel, data, wheel)
- .on(events.start, data, start)
- .on(events.end, data, stop)
- .on(events.scroll, data, scroll)
- .on(events.ignored, false);
-
- // apply the stop listeners for drag end
- if(options.dragHold) {
- $(document).on(events.end, data, stop);
- } else {
- data.target.on(events.end, data, stop);
- }
-
- // apply any user-provided scroll offsets
- if (options.scrollLeft !== null) {
- target.scrollLeft(options.scrollLeft);
- } if (options.scrollTop !== null) {
- target.scrollTop(options.scrollTop);
- }
+ // apply any user-provided scroll offsets
+ if (options.scrollLeft !== null) {
+ target.scrollLeft(options.scrollLeft);
+ } if (options.scrollTop !== null) {
+ target.scrollTop(options.scrollTop);
+ }
- // add thumbs and listeners (if we're showing them)
- if (options.showThumbs) {
- data.thumbs = thumbs = createThumbs(target, sizing, options);
- if (thumbs.added) {
- moveThumbs(thumbs, sizing, target.scrollLeft(), target.scrollTop());
- if (options.hoverThumbs) {
- target.on(events.hover, data, hover);
+ // add thumbs and listeners (if we're showing them)
+ if (options.showThumbs) {
+ data.thumbs = thumbs = createThumbs(target, sizing, options);
+ if (thumbs.added) {
+ moveThumbs(thumbs, sizing, target.scrollLeft(), target.scrollTop());
+ if (options.hoverThumbs) {
+ target.on(events.hover, data, hover);
+ }
}
}
- }
- target.data(datakey, data);
+ target.data(datakey, data);
+ }
},
@@ -714,4 +722,4 @@
removeOverscroll: removeOverscroll
});
-})(window, document, Math, setTimeout, clearTimeout, jQuery.fn, jQuery);
+})(window, document, navigator, Math, setTimeout, clearTimeout, jQuery.fn, jQuery);
View
10 jquery.overscroll.min.js
@@ -1,8 +1,2 @@
-/**
- * Overscroll v1.6.2
- * http://azoffdesign.com/overscroll
- *
- * Copyright 2012, Jonathan Azoff
- * Dual licensed under the MIT or GPL Version 2 licenses.
- * http://jquery.org/license
- */(function(a,b,c,d,e,f,g,h){"use strict";var i="overscroll",j=function(){var c=g.browser,e,f=b.createElement(i).style,k=c.webkit?"webkit":c.mozilla?"moz":c.msie?"ms":c.opera?"o":"",l=k?["-","-"].join(k):"";return j={prefix:k,overflowScrolling:!1},g.each(k?[k,""]:[k],function(b,c){var d=c?c+"RequestAnimationFrame":"requestAnimationFrame",e=c?c+"OverflowScrolling":"overflowScrolling";a[d]!==h&&(j.animate=function(b){a[d].call(a,b)}),f[e]!==h?j.overflowScrolling=l+"overflow-scrolling":!j.touchEvents}),j.touchEvents="ontouchstart"in a,j.animate||(j.animate=function(a){d(a,1e3/60)}),k==="moz"||k==="webkit"?(j.cursorGrab=l+"grab",j.cursorGrabbing=l+"grabbing"):(e="https://mail.google.com/mail/images/2/",j.cursorGrab="url("+e+"openhand.cur), default",j.cursorGrabbing="url("+e+"closedhand.cur), default"),j}(),k={drag:"mousemove touchmove",end:"mouseup mouseleave click touchend touchcancel",hover:"mouseenter mouseleave",ignored:"select dragstart drag",scroll:"scroll",start:"mousedown touchstart",wheel:"mousewheel DOMMouseScroll"},l={captureThreshold:3,driftDecay:1.1,driftSequences:22,driftTimeout:100,scrollDelta:15,thumbOpacity:.7,thumbThickness:6,thumbTimeout:400,wheelDelta:20},m={cancelOn:"",direction:"multi",dragHold:!1,hoverThumbs:!1,scrollDelta:l.scrollDelta,showThumbs:!0,persistThumbs:!1,wheelDelta:l.wheelDelta,wheelDirection:"vertical",zIndex:999},n=function(a,b){b.trigger("overscroll:"+a)},o=function(){return(new Date).getTime()},p=function(a,b,c){return b.x=a.pageX,b.y=a.pageY,b.time=o(),b.index=c,b},q=function(a,b,c,d){var e,f;a&&a.added&&(a.horizontal&&(e=c*(1+b.container.width/b.container.scrollWidth),f=d+b.thumbs.horizontal.top,a.horizontal.css("margin",f+"px 0 0 "+e+"px")),a.vertical&&(e=c+b.thumbs.vertical.left,f=d*(1+b.container.height/b.container.scrollHeight),a.vertical.css("margin",f+"px 0 0 "+e+"px")))},r=function(a,b,c){a&&a.added&&!b.persistThumbs&&(c?(a.vertical&&a.vertical.stop(!0,!0).fadeTo("fast",l.thumbOpacity),a.horizontal&&a.horizontal.stop(!0,!0).fadeTo("fast",l.thumbOpacity)):(a.vertical&&a.vertical.fadeTo("fast",0),a.horizontal&&a.horizontal.fadeTo("fast",0)))},s=function(a){var b=a.data("events"),c=b&&b.click?b.click.slice():[];b&&delete b.click,a.one("mouseup touchend touchcancel",function(){return g.each(c,function(b,c){a.click(c)}),!1})},t=function(a){var b=a.data,c=b.thumbs,d=b.options,e=a.type==="mouseenter";r(c,d,e)},u=function(a){var b=a.data;b.flags.dragged||q(b.thumbs,b.sizing,this.scrollLeft,this.scrollTop)},v=function(a){a.preventDefault();var b=a.data,c=b.options,f=b.sizing,g=b.thumbs,h=b.wheel,k=b.flags,m,n=a.originalEvent;k.drifting=!1,n.wheelDelta&&(m=n.wheelDelta/(j.prefix==="o"?-120:120)),n.detail&&(m=-n.detail/3),m*=c.wheelDelta,h||(b.target.data(i).dragging=k.dragging=!0,b.wheel=h={timeout:null},r(g,c,!0)),c.wheelDirection==="horizontal"?this.scrollLeft-=m:this.scrollTop-=m,h.timeout&&e(h.timeout),q(g,f,this.scrollLeft,this.scrollTop),h.timeout=d(function(){b.target.data(i).dragging=k.dragging=!1,r(g,c,b.wheel=null)},l.thumbTimeout)},w=function(a){a.preventDefault();var b=a.data,c=a.originalEvent.touches,d=b.options,e=b.sizing,f=b.thumbs,g=b.position,h=b.flags,k=b.target.get(0);j.touchEvents&&c&&c.length&&(a=c[0]),h.dragged||r(f,d,!0),h.dragged=!0,d.direction!=="vertical"&&(k.scrollLeft-=a.pageX-g.x),b.options.direction!=="horizontal"&&(k.scrollTop-=a.pageY-g.y),p(a,b.position),--b.capture.index<=0&&(b.target.data(i).dragging=h.dragging=!0,p(a,b.capture,l.captureThreshold)),q(f,e,k.scrollLeft,k.scrollTop)},x=function(a,b,c){var d=b.data,e,f,g,h,i=d.capture,k=d.options,m=d.sizing,p=d.thumbs,r=o()-i.time,s=a.scrollLeft,t=a.scrollTop,u=l.driftDecay;if(r>l.driftTimeout)return c(d);e=k.scrollDelta*(b.pageX-i.x),f=k.scrollDelta*(b.pageY-i.y),k.direction!=="vertical"&&(s-=e),k.direction!=="horizontal"&&(t-=f),g=e/l.driftSequences,h=f/l.driftSequences,n("driftstart",d.target),d.drifting=!0,j.animate(function v(){if(d.drifting){var b=1,e=-1;d.drifting=!1;if(h>b&&a.scrollTop>t||h<e&&a.scrollTop<t)d.drifting=!0,a.scrollTop-=h,h/=u;if(g>b&&a.scrollLeft>s||g<e&&a.scrollLeft<s)d.drifting=!0,a.scrollLeft-=g,g/=u;q(p,m,a.scrollLeft,a.scrollTop),j.animate(v)}else n("driftend",d.target),c(d)})},y=function(a){var b=a.data,c=b.target,d=b.start=g(a.target),e=b.flags;e.drifting=!1,d.size()&&!d.is(b.options.cancelOn)&&(j.touchEvents||a.preventDefault(),c.css("cursor",j.cursorGrabbing),c.data(i).dragging=e.dragging=e.dragged=!1,b.options.dragHold?g(document).on(k.drag,b,w):c.on(k.drag,b,w),b.position=p(a,{}),b.capture=p(a,{},l.captureThreshold),n("dragstart",c))},z=function(a){var b=a.data,c=b.target,d=b.options,e=b.flags,f=b.thumbs,h=function(){f&&!d.hoverThumbs&&r(f,d,!1)};d.dragHold?g(document).unbind(k.drag,w):c.unbind(k.drag,w),b.position&&(n("dragend",c),e.dragging?x(c.get(0),a,h):h()),e.dragging&&b.start.is(a.target)&&s(b.start),c.data(i).dragging=b.start=b.capture=b.position=e.dragged=e.dragging=!1,c.css("cursor",j.cursorGrab)},A=function(a){return a=g.extend({},m,a),a.direction!=="multi"&&a.direction!==a.wheelDirection&&(a.wheelDirection=a.direction),a.scrollDelta=c.abs(a.scrollDelta),a.wheelDelta=c.abs(a.wheelDelta),a.scrollLeft=a.scrollLeft===h?null:c.abs(a.scrollLeft),a.scrollTop=a.scrollTop===h?null:c.abs(a.scrollTop),a},B=function(a){var b=g(a),c=b.width(),d=b.height(),e=c>=a.scrollWidth?c:a.scrollWidth,f=d>=a.scrollHeight?d:a.scrollHeight;return{container:{width:c,height:d,scrollWidth:e,scrollHeight:f},thumbs:{horizontal:{width:c*c/e,height:l.thumbThickness,corner:l.thumbThickness/2,left:0,top:d-l.thumbThickness},vertical:{width:l.thumbThickness,height:d*d/f,corner:l.thumbThickness/2,left:c-l.thumbThickness,top:0}}}},C=function(a,b){var c=g(a),d,e=c.data(i)||{},f=c.attr("style"),h=b?function(){e=c.data(i),d=e.thumbs,f?c.attr("style",f):c.removeAttr("style"),d&&(d.horizontal&&d.horizontal.remove(),d.vertical&&d.vertical.remove()),c.removeData(i).off(k.wheel,v).off(k.start,y).off(k.end,z).off(k.ignored,!1)}:g.noop;return g.isFunction(e.remover)?e.remover:h},D=function(a,b){return{position:"absolute",opacity:b.persistThumbs?l.thumbOpacity:0,"background-color":"black",width:a.width+"px",height:a.height+"px","border-radius":a.corner+"px",margin:a.top+"px 0 0 "+a.left+"px","z-index":b.zIndex}},E=function(a,b,c){var d="<div/>",e={},f=!1;return b.container.scrollWidth>0&&c.direction!=="vertical"&&(f=D(b.thumbs.horizontal,c),e.horizontal=g(d).css(f).prependTo(a)),b.container.scrollHeight>0&&c.direction!=="horizontal"&&(f=D(b.thumbs.vertical,c),e.vertical=g(d).css(f).prependTo(a)),e.added=!!f,e},F=function(a,b){var c,d,e={flags:{dragging:!1},options:b=A(b),remover:C(a,!0),sizing:d=B(a)};e.target=a=g(a).css({position:"relative",overflow:"hidden",cursor:j.cursorGrab}).on(k.wheel,e,v).on(k.start,e,y).on(k.end,e,z).on(k.scroll,e,u).on(k.ignored,!1),b.dragHold?g(document).on(k.end,e,z):e.target.on(k.end,e,z),b.scrollLeft!==null&&a.scrollLeft(b.scrollLeft),b.scrollTop!==null&&a.scrollTop(b.scrollTop),b.showThumbs&&(e.thumbs=c=E(a,d,b),c.added&&(q(c,d,a.scrollLeft(),a.scrollTop()),b.hoverThumbs&&a.on(k.hover,e,t))),a.data(i,e)},G=function(a){C(a)()},H=function(a){return this.removeOverscroll().each(function(){F(this,a)})},I=function(){return this.removeOverscroll().each(function(){g(this).data(i,{remover:C(this)}).css(j.overflowScrolling,"touch").css("overflow","auto")})},J=function(){return this.each(function(){G(this)})};H.settings=l,g.extend(f,{overscroll:j.overflowScrolling?I:H,removeOverscroll:J})})(window,document,Math,setTimeout,clearTimeout,jQuery.fn,jQuery);
+/* Overscroll v1.6.3 (C) 2012 - MIT+GPLv2 - http://azof.fr/KwOhTJ */
+(function(a,b,c,d,e,f,g,h,i){"use strict";var j="overscroll",k=function(){var d=h.browser,f,g=c.userAgent,l=b.createElement(j).style,m=d.webkit?"webkit":d.mozilla?"moz":d.msie?"ms":d.opera?"o":"",n=m?["-","-"].join(m):"";return k={prefix:m,overflowScrolling:!1},h.each(m?[m,""]:[m],function(b,c){var d=c?c+"RequestAnimationFrame":"requestAnimationFrame",e=c?c+"OverflowScrolling":"overflowScrolling";a[d]!==i&&(k.animate=function(b){a[d].call(a,b)}),l[e]!==i&&g.indexOf("Chrome")<0&&(k.overflowScrolling=n+"overflow-scrolling")}),k.touchEvents="ontouchstart"in a,k.animate||(k.animate=function(a){e(a,1e3/60)}),m==="moz"||m==="webkit"?(k.cursorGrab=n+"grab",k.cursorGrabbing=n+"grabbing"):(f="https://mail.google.com/mail/images/2/",k.cursorGrab="url("+f+"openhand.cur), default",k.cursorGrabbing="url("+f+"closedhand.cur), default"),k}(),l={drag:"mousemove touchmove",end:"mouseup mouseleave click touchend touchcancel",hover:"mouseenter mouseleave",ignored:"select dragstart drag",scroll:"scroll",start:"mousedown touchstart",wheel:"mousewheel DOMMouseScroll"},m={captureThreshold:3,driftDecay:1.1,driftSequences:22,driftTimeout:100,scrollDelta:15,thumbOpacity:.7,thumbThickness:6,thumbTimeout:400,wheelDelta:20},n={cancelOn:"",direction:"multi",dragHold:!1,hoverThumbs:!1,scrollDelta:m.scrollDelta,showThumbs:!0,persistThumbs:!1,wheelDelta:m.wheelDelta,wheelDirection:"vertical",zIndex:999},o=function(a,b){b.trigger("overscroll:"+a)},p=function(){return(new Date).getTime()},q=function(a,b,c){return b.x=a.pageX,b.y=a.pageY,b.time=p(),b.index=c,b},r=function(a,b,c,d){var e,f;a&&a.added&&(a.horizontal&&(e=c*(1+b.container.width/b.container.scrollWidth),f=d+b.thumbs.horizontal.top,a.horizontal.css("margin",f+"px 0 0 "+e+"px")),a.vertical&&(e=c+b.thumbs.vertical.left,f=d*(1+b.container.height/b.container.scrollHeight),a.vertical.css("margin",f+"px 0 0 "+e+"px")))},s=function(a,b,c){a&&a.added&&!b.persistThumbs&&(c?(a.vertical&&a.vertical.stop(!0,!0).fadeTo("fast",m.thumbOpacity),a.horizontal&&a.horizontal.stop(!0,!0).fadeTo("fast",m.thumbOpacity)):(a.vertical&&a.vertical.fadeTo("fast",0),a.horizontal&&a.horizontal.fadeTo("fast",0)))},t=function(a){var b=a.data("events"),c=b&&b.click?b.click.slice():[];b&&delete b.click,a.one("mouseup touchend touchcancel",function(){return h.each(c,function(b,c){a.click(c)}),!1})},u=function(a){var b=a.data,c=b.thumbs,d=b.options,e=a.type==="mouseenter";s(c,d,e)},v=function(a){var b=a.data;b.flags.dragged||r(b.thumbs,b.sizing,this.scrollLeft,this.scrollTop)},w=function(a){a.preventDefault();var b=a.data,c=b.options,d=b.sizing,g=b.thumbs,h=b.wheel,i=b.flags,l,n=a.originalEvent;i.drifting=!1,n.wheelDelta&&(l=n.wheelDelta/(k.prefix==="o"?-120:120)),n.detail&&(l=-n.detail/3),l*=c.wheelDelta,h||(b.target.data(j).dragging=i.dragging=!0,b.wheel=h={timeout:null},s(g,c,!0)),c.wheelDirection==="horizontal"?this.scrollLeft-=l:this.scrollTop-=l,h.timeout&&f(h.timeout),r(g,d,this.scrollLeft,this.scrollTop),h.timeout=e(function(){b.target.data(j).dragging=i.dragging=!1,s(g,c,b.wheel=null)},m.thumbTimeout)},x=function(a){a.preventDefault();var b=a.data,c=a.originalEvent.touches,d=b.options,e=b.sizing,f=b.thumbs,g=b.position,h=b.flags,i=b.target.get(0);k.touchEvents&&c&&c.length&&(a=c[0]),h.dragged||s(f,d,!0),h.dragged=!0,d.direction!=="vertical"&&(i.scrollLeft-=a.pageX-g.x),b.options.direction!=="horizontal"&&(i.scrollTop-=a.pageY-g.y),q(a,b.position),--b.capture.index<=0&&(b.target.data(j).dragging=h.dragging=!0,q(a,b.capture,m.captureThreshold)),r(f,e,i.scrollLeft,i.scrollTop)},y=function(a,b,c){var d=b.data,e,f,g,h,i=d.capture,j=d.options,l=d.sizing,n=d.thumbs,q=p()-i.time,s=a.scrollLeft,t=a.scrollTop,u=m.driftDecay;if(q>m.driftTimeout)return c(d);e=j.scrollDelta*(b.pageX-i.x),f=j.scrollDelta*(b.pageY-i.y),j.direction!=="vertical"&&(s-=e),j.direction!=="horizontal"&&(t-=f),g=e/m.driftSequences,h=f/m.driftSequences,o("driftstart",d.target),d.drifting=!0,k.animate(function v(){if(d.drifting){var b=1,e=-1;d.drifting=!1;if(h>b&&a.scrollTop>t||h<e&&a.scrollTop<t)d.drifting=!0,a.scrollTop-=h,h/=u;if(g>b&&a.scrollLeft>s||g<e&&a.scrollLeft<s)d.drifting=!0,a.scrollLeft-=g,g/=u;r(n,l,a.scrollLeft,a.scrollTop),k.animate(v)}else o("driftend",d.target),c(d)})},z=function(a){var b=a.data,c=b.target,d=b.start=h(a.target),e=b.flags;e.drifting=!1,d.size()&&!d.is(b.options.cancelOn)&&(k.touchEvents||a.preventDefault(),c.css("cursor",k.cursorGrabbing),c.data(j).dragging=e.dragging=e.dragged=!1,b.options.dragHold?h(document).on(l.drag,b,x):c.on(l.drag,b,x),b.position=q(a,{}),b.capture=q(a,{},m.captureThreshold),o("dragstart",c))},A=function(a){var b=a.data,c=b.target,d=b.options,e=b.flags,f=b.thumbs,g=function(){f&&!d.hoverThumbs&&s(f,d,!1)};d.dragHold?h(document).unbind(l.drag,x):c.unbind(l.drag,x),b.position&&(o("dragend",c),e.dragging?y(c.get(0),a,g):g()),e.dragging&&b.start.is(a.target)&&t(b.start),c.data(j).dragging=b.start=b.capture=b.position=e.dragged=e.dragging=!1,c.css("cursor",k.cursorGrab)},B=function(a){return a=h.extend({},n,a),a.direction!=="multi"&&a.direction!==a.wheelDirection&&(a.wheelDirection=a.direction),a.scrollDelta=d.abs(a.scrollDelta),a.wheelDelta=d.abs(a.wheelDelta),a.scrollLeft=a.scrollLeft===i?null:d.abs(a.scrollLeft),a.scrollTop=a.scrollTop===i?null:d.abs(a.scrollTop),a},C=function(a){var b=h(a),c=b.width(),d=b.height(),e=c>=a.scrollWidth?c:a.scrollWidth,f=d>=a.scrollHeight?d:a.scrollHeight,g=e>c||f>d;return{valid:g,container:{width:c,height:d,scrollWidth:e,scrollHeight:f},thumbs:{horizontal:{width:c*c/e,height:m.thumbThickness,corner:m.thumbThickness/2,left:0,top:d-m.thumbThickness},vertical:{width:m.thumbThickness,height:d*d/f,corner:m.thumbThickness/2,left:c-m.thumbThickness,top:0}}}},D=function(a,b){var c=h(a),d,e=c.data(j)||{},f=c.attr("style"),g=b?function(){e=c.data(j),d=e.thumbs,f?c.attr("style",f):c.removeAttr("style"),d&&(d.horizontal&&d.horizontal.remove(),d.vertical&&d.vertical.remove()),c.removeData(j).off(l.wheel,w).off(l.start,z).off(l.end,A).off(l.ignored,!1)}:h.noop;return h.isFunction(e.remover)?e.remover:g},E=function(a,b){return{position:"absolute",opacity:b.persistThumbs?m.thumbOpacity:0,"background-color":"black",width:a.width+"px",height:a.height+"px","border-radius":a.corner+"px",margin:a.top+"px 0 0 "+a.left+"px","z-index":b.zIndex}},F=function(a,b,c){var d="<div/>",e={},f=!1;return b.container.scrollWidth>0&&c.direction!=="vertical"&&(f=E(b.thumbs.horizontal,c),e.horizontal=h(d).css(f).prependTo(a)),b.container.scrollHeight>0&&c.direction!=="horizontal"&&(f=E(b.thumbs.vertical,c),e.vertical=h(d).css(f).prependTo(a)),e.added=!!f,e},G=function(a,b){b=B(b);var c=C(a),d,e={options:b,sizing:c,flags:{dragging:!1},remover:D(a,!0)};c.valid&&(e.target=a=h(a).css({position:"relative",overflow:"hidden",cursor:k.cursorGrab}).on(l.wheel,e,w).on(l.start,e,z).on(l.end,e,A).on(l.scroll,e,v).on(l.ignored,!1),b.dragHold?h(document).on(l.end,e,A):e.target.on(l.end,e,A),b.scrollLeft!==null&&a.scrollLeft(b.scrollLeft),b.scrollTop!==null&&a.scrollTop(b.scrollTop),b.showThumbs&&(e.thumbs=d=F(a,c,b),d.added&&(r(d,c,a.scrollLeft(),a.scrollTop()),b.hoverThumbs&&a.on(l.hover,e,u))),a.data(j,e))},H=function(a){D(a)()},I=function(a){return this.removeOverscroll().each(function(){G(this,a)})},J=function(){return this.removeOverscroll().each(function(){h(this).data(j,{remover:D(this)}).css(k.overflowScrolling,"touch").css("overflow","auto")})},K=function(){return this.each(function(){H(this)})};I.settings=m,h.extend(g,{overscroll:k.overflowScrolling?J:I,removeOverscroll:K})})(window,document,navigator,Math,setTimeout,clearTimeout,jQuery.fn,jQuery);
Please sign in to comment.
Something went wrong with that request. Please try again.