Skip to content
Browse files

Updated minified scripts and copy

  • Loading branch information...
1 parent ff58566 commit 72262a78439e1d75ccff1ed9dabd007d54abd278 Jonathan Azoff committed Apr 12, 2012
Showing with 112 additions and 115 deletions.
  1. +9 −2 README.md
  2. +100 −100 jquery.overscroll.js
  3. +2 −12 jquery.overscroll.min.js
  4. +1 −1 package.json
View
11 README.md
@@ -1,6 +1,6 @@
-Overscroll v1.6.1
+Overscroll v1.6.2
=================
-Saturday, February 18th 2012
+Thursday, April 12th 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).
@@ -103,6 +103,13 @@ As of 1.4.4 you can call the `overscroll` constructor on a jQuery element as muc
Change Log
----------
+ * __1.6.2__
+ - Explicit check for start element.
+ + <https://github.com/azoff/Overscroll/issues/48>
+ - Added support for android devices.
+ + <https://github.com/azoff/Overscroll/issues/51>
+ - Added dragHold feature support.
+ + <https://github.com/azoff/Overscroll/issues/49>
* __1.6.1__
- Fixed feature detection and dragging data flag.
+ <https://github.com/azoff/Overscroll/issues/41>
View
200 jquery.overscroll.js
@@ -21,15 +21,15 @@
/*global window, document, setTimeout, clearTimeout, jQuery */
(function(global, dom, math, wait, cancel, namespace, $, none){
-
+
// We want to run this plug-in in strict-mode
// so that we may benefit from any optimizations
// strict execution
'use strict';
-
+
// The key used to bind-instance specific data to an object
var datakey = 'overscroll',
-
+
// runs feature detection for overscroll
compat = (function(){
var b = $.browser, fallback,
@@ -40,39 +40,39 @@
$.each(prefix ? [prefix, ''] : [prefix], function(i, prefix){
var animator = prefix ? (prefix + 'RequestAnimationFrame') : 'requestAnimationFrame',
scroller = prefix ? (prefix + 'OverflowScrolling') : 'overflowScrolling';
-
+
// check to see if requestAnimationFrame is available
if (global[animator] !== none) {
compat.animate = function(callback){
global[animator].call(global, callback);
};
}
-
+
// check to see if overflowScrolling is available
if (style[scroller] !== none) {
compat.overflowScrolling = cssprefix + 'overflow-scrolling';
} else if (compat.touchEvents) {
-
- }
-
-
+
+ }
+
+
});
-
- // check to see if the client supports touch
- compat.touchEvents = 'ontouchstart' in global;
-
+
+ // check to see if the client supports touch
+ compat.touchEvents = 'ontouchstart' in global;
+
// fallback to set timeout for no animation support
if (!compat.animate) {
compat.animate = function(callback) {
wait(callback, 1000/60);
};
}
-
+
// firefox and webkit browsers support native grabbing cursors
if (prefix === 'moz' || prefix === 'webkit') {
compat.cursorGrab = cssprefix + 'grab';
compat.cursorGrabbing = cssprefix + 'grabbing';
-
+
// other browsers can user google's assets
} else {
fallback = 'https://mail.google.com/mail/images/2/';
@@ -81,19 +81,19 @@
}
return compat;
})(),
-
+
// These are all the events that could possibly
// be used by the plug-in
events = {
- drag: 'mousemove touchmove',
+ drag: 'mousemove touchmove',
end: 'mouseup mouseleave click touchend touchcancel',
hover: 'mouseenter mouseleave',
ignored: 'select dragstart drag',
scroll: 'scroll',
start: 'mousedown touchstart',
wheel: 'mousewheel DOMMouseScroll'
},
-
+
// These settings are used to tweak drift settings
// for the plug-in
settings = {
@@ -107,13 +107,13 @@
thumbTimeout: 400,
wheelDelta: 20
},
-
+
// These defaults are used to complement any options
// passed into the plug-in entry point
defaults = {
cancelOn: '',
direction: 'multi',
- dragHold: false,
+ dragHold: false,
hoverThumbs: false,
scrollDelta: settings.scrollDelta,
showThumbs: true,
@@ -122,18 +122,18 @@
wheelDirection: 'vertical',
zIndex: 999
},
-
+
// Triggers a DOM event on the overscrolled element.
// All events are namespaced under the overscroll name
triggerEvent = function (event, target) {
target.trigger('overscroll:' + event);
},
-
+
// Utility function to return a timestamp
time = function() {
return (new Date()).getTime();
},
-
+
// Captures the position from an event, modifies the properties
// of the second argument to persist the position, and then
// returns the modified object
@@ -144,7 +144,7 @@
position.index = index;
return position;
},
-
+
// Used to move the thumbs around an overscrolled element
moveThumbs = function (thumbs, sizing, left, top) {
@@ -164,7 +164,7 @@
}
},
-
+
// Used to toggle the thumbs on and off
// of an overscrolled element
toggleThumbs = function (thumbs, options, dragging) {
@@ -186,7 +186,7 @@
}
}
},
-
+
// Defers click event listeners to after a mouseup event.
// Used to avoid unintentional clicks
deferClick = function (target) {
@@ -219,13 +219,13 @@
moveThumbs(data.thumbs, data.sizing, this.scrollLeft, this.scrollTop);
}
},
-
+
// handles mouse wheel scroll events
wheel = function (event) {
-
+
// prevent any default wheel behavior
event.preventDefault();
-
+
var data = event.data,
options = data.options,
sizing = data.sizing,
@@ -251,7 +251,7 @@
data.wheel = wheel = { timeout: null };
toggleThumbs(thumbs, options, true);
}
-
+
// actually modify scroll offsets
if (options.wheelDirection === 'horizontal') {
this.scrollLeft -= delta;
@@ -272,36 +272,36 @@
// updates the current scroll offset during a mouse move
drag = function (event) {
-
- event.preventDefault();
+
+ event.preventDefault();
var data = event.data,
- touches = event.originalEvent.touches,
+ touches = event.originalEvent.touches,
options = data.options,
sizing = data.sizing,
thumbs = data.thumbs,
position = data.position,
flags = data.flags,
- target = data.target.get(0);
-
-
- // correct page coordinates for touch devices
- if (compat.touchEvents && touches && touches.length) {
- event = touches[0];
- }
-
+ target = data.target.get(0);
+
+
+ // correct page coordinates for touch devices
+ if (compat.touchEvents && touches && touches.length) {
+ event = touches[0];
+ }
+
if (!flags.dragged) {
toggleThumbs(thumbs, options, true);
}
flags.dragged = true;
if (options.direction !== 'vertical') {
- target.scrollLeft -= (event.pageX - position.x);
+ target.scrollLeft -= (event.pageX - position.x);
}
if (data.options.direction !== 'horizontal') {
- target.scrollTop -= (event.pageY - position.y);
+ target.scrollTop -= (event.pageY - position.y);
}
capturePosition(event, data.position);
@@ -310,11 +310,11 @@
data.target.data(datakey).dragging = flags.dragging = true;
capturePosition(event, data.capture, settings.captureThreshold);
}
-
+
moveThumbs(thumbs, sizing, target.scrollLeft, target.scrollTop);
},
-
+
// sends the overscrolled element into a drift
drift = function (target, event, callback) {
@@ -333,18 +333,18 @@
if (elapsed > settings.driftTimeout) {
return callback(data);
}
-
+
// determine offset between last capture and current time
dx = options.scrollDelta * (event.pageX - capture.x);
dy = options.scrollDelta * (event.pageY - capture.y);
-
+
// update target scroll offsets
if (options.direction !== 'vertical') {
scrollLeft -= dx;
} if (options.direction !== 'horizontal') {
scrollTop -= dy;
}
-
+
// split the distance to travel into a set of sequences
xMod = dx / settings.driftSequences;
yMod = dy / settings.driftSequences;
@@ -377,7 +377,7 @@
});
},
-
+
// starts the drag operation and binds the mouse move handler
start = function (event) {
@@ -390,23 +390,23 @@
flags.drifting = false;
// only start drag if the user has not explictly banned it.
- if (start.size() && !start.is(data.options.cancelOn)) {
-
- // without this the simple "click" event won't be recognized on touch clients
- if (!compat.touchEvents) {
- event.preventDefault();
- }
-
+ if (start.size() && !start.is(data.options.cancelOn)) {
+
+ // without this the simple "click" event won't be recognized on touch clients
+ if (!compat.touchEvents) {
+ event.preventDefault();
+ }
+
target.css('cursor', compat.cursorGrabbing);
target.data(datakey).dragging = flags.dragging = flags.dragged = false;
-
- // apply the drag listeners to the doc or target
+
+ // apply the drag listeners to the doc or target
if(data.options.dragHold) {
$(document).on(events.drag, data, drag);
} else {
target.on(events.drag, data, drag);
}
-
+
data.position = capturePosition(event, {});
data.capture = capturePosition(event, {}, settings.captureThreshold);
triggerEvent('dragstart', target);
@@ -422,15 +422,15 @@
options = data.options,
flags = data.flags,
thumbs = data.thumbs,
-
+
// hides the thumbs after the animation is done
done = function () {
if (thumbs && !options.hoverThumbs) {
toggleThumbs(thumbs, options, false);
}
};
- // remove drag listeners from doc or target
+ // remove drag listeners from doc or target
if(options.dragHold) {
$(document).unbind(events.drag, drag);
} else {
@@ -449,15 +449,15 @@
} else {
done();
}
-
+
}
-
+
// only if we moved, and the mouse down is the same as
// the mouse up target do we defer the event
if (flags.dragging && data.start.is(event.target)) {
deferClick(data.start);
}
-
+
// clear all internal flags and settings
target.data(datakey).dragging =
data.start =
@@ -470,14 +470,14 @@
target.css('cursor', compat.cursorGrab);
},
-
+
// Ensures that a full set of options are provided
// for the plug-in. Also does some validation
getOptions = function(options) {
-
+
// fill in missing values with defaults
options = $.extend({}, defaults, options);
-
+
// check for inconsistent directional restrictions
if (options.direction !== 'multi' && options.direction !== options.wheelDirection) {
options.wheelDirection = options.direction;
@@ -486,15 +486,15 @@
// ensure positive values for deltas
options.scrollDelta = math.abs(options.scrollDelta);
options.wheelDelta = math.abs(options.wheelDelta);
-
+
// fix values for scroll offset
options.scrollLeft = options.scrollLeft === none ? null : math.abs(options.scrollLeft);
options.scrollTop = options.scrollTop === none ? null : math.abs(options.scrollTop);
-
+
return options;
-
+
},
-
+
// Returns the sizing information (bounding box) for the
// target DOM element
getSizing = function (target) {
@@ -504,7 +504,7 @@
height = $target.height(),
scrollWidth = width >= target.scrollWidth ? width : target.scrollWidth,
scrollHeight = height >= target.scrollHeight ? height : target.scrollHeight;
-
+
return {
container: {
width: width,
@@ -531,12 +531,12 @@
};
},
-
+
// Attempts to get (or implicitly creates) the
// remover function for the target passed
// in as an argument
getRemover = function (target, orCreate) {
-
+
var $target = $(target), thumbs,
data = $target.data(datakey) || {},
style = $target.attr('style'),
@@ -551,7 +551,7 @@
} else {
$target.removeAttr('style');
}
-
+
// remove any created thumbs
if (thumbs) {
if (thumbs.horizontal) { thumbs.horizontal.remove(); }
@@ -565,13 +565,13 @@
.off(events.start, start)
.off(events.end, stop)
.off(events.ignored, false);
-
+
} : $.noop;
-
+
return $.isFunction(data.remover) ? data.remover : fallback;
-
+
},
-
+
// Genterates CSS specific to a particular thumb.
// It requires sizing data and options
getThumbCss = function(size, options) {
@@ -586,15 +586,15 @@
'z-index': options.zIndex
};
},
-
+
// Creates the DOM elements used as "thumbs" within
// the target container.
createThumbs = function(target, sizing, options) {
-
+
var div = '<div/>',
thumbs = {},
css = false;
-
+
if (sizing.container.scrollWidth > 0 && options.direction !== 'vertical') {
css = getThumbCss(sizing.thumbs.horizontal, options);
thumbs.horizontal = $(div).css(css).prependTo(target);
@@ -606,16 +606,16 @@
}
thumbs.added = !!css;
-
+
return thumbs;
-
+
},
-
+
// 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) {
-
+
// create initial data properties for this instance
var thumbs, sizing,
data = {
@@ -624,7 +624,7 @@
remover: getRemover(target, true),
sizing: sizing = getSizing(target)
};
-
+
// provide a circular-reference, enable events, and
// apply any required CSS
data.target = target = $(target).css({
@@ -636,21 +636,21 @@
.on(events.end, data, stop)
.on(events.scroll, data, scroll)
.on(events.ignored, false);
-
- // apply the stop listeners for drag end
+
+ // 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);
}
-
+
// add thumbs and listeners (if we're showing them)
if (options.showThumbs) {
data.thumbs = thumbs = createThumbs(target, sizing, options);
@@ -661,18 +661,18 @@
}
}
}
-
+
target.data(datakey, data);
-
+
},
-
+
// Removes any event listeners and other instance-specific
// data from the target. It attempts to leave the target
// at the state it found it.
teardown = function(target) {
getRemover(target)();
},
-
+
// This is the entry-point for enabling the plug-in;
// You can find it's exposure point at the end
// of this closure
@@ -681,7 +681,7 @@
setup(this, options);
});
},
-
+
// This function applies touch-specific CSS to enable
// the behavior that Overscroll emulates. This function
// is called instead of overscroll if the device supports
@@ -693,7 +693,7 @@
.css('overflow', 'auto');
});
},
-
+
// This is the entry-point for disabling the plug-in;
// You can find it's exposure point at the end
// of this closure
@@ -702,16 +702,16 @@
teardown(this);
});
};
-
+
// Extend overscroll to expose settings to the user
overscroll.settings = settings;
-
+
// Extend jQuery's prototype to expose the plug-in.
// If the supports native overflowScrolling, overscroll will not
// attempt to override the browser's built in support
$.extend(namespace, {
overscroll: compat.overflowScrolling ? touchscroll : overscroll,
removeOverscroll: removeOverscroll
});
-
+
})(window, document, Math, setTimeout, clearTimeout, jQuery.fn, jQuery);
View
14 jquery.overscroll.min.js
@@ -1,18 +1,8 @@
/**
- * Overscroll v1.6.1
- * A jQuery Plugin that emulates the iPhone scrolling experience in a browser.
+ * Overscroll v1.6.2
* http://azoffdesign.com/overscroll
*
- * Intended for use with the latest jQuery
- * http://code.jquery.com/jquery-latest.js
- *
* Copyright 2012, Jonathan Azoff
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
- *
- * For API documentation, see the README file
- * http://azof.fr/pYCzuM
- *
- * Date: Saturday, February 18th 2012
- */
-(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.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",end:"mouseup mouseleave click",hover:"mouseenter mouseleave",ignored:"select dragstart drag",scroll:"scroll",start:"mousedown",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",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",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=b.options,d=b.sizing,e=b.thumbs,f=b.position,g=b.flags;g.dragged||r(e,c,!0),g.dragged=!0,c.direction!=="vertical"&&(this.scrollLeft-=a.pageX-f.x),b.options.direction!=="horizontal"&&(this.scrollTop-=a.pageY-f.y),p(a,b.position),--b.capture.index<=0&&(b.target.data(i).dragging=g.dragging=!0,p(a,b.capture,l.captureThreshold)),q(e,d,this.scrollLeft,this.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.is(b.options.cancelOn)||(a.preventDefault(),c.css("cursor",j.cursorGrabbing),c.data(i).dragging=e.dragging=e.dragged=!1,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,g=function(){f&&!d.hoverThumbs&&r(f,d,!1)};c.unbind(k.drag,w),b.position&&(n("dragend",c),e.dragging?x(this,a,g):g()),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.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(a){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);
+ */(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);
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "overscroll",
- "version": "1.6.0",
+ "version": "1.6.2",
"title": "jQuery.Overscroll()",
"author": {
"name": "Jonathan Azoff",

0 comments on commit 72262a7

Please sign in to comment.
Something went wrong with that request. Please try again.