Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: azoff/overscroll
base: 5ed407bb13
...
head fork: azoff/overscroll
compare: 72262a7843
Checking mergeability… Don't worry, you can still create the pull request.
  • 7 commits
  • 5 files changed
  • 0 commit comments
  • 3 contributors
Commits on Mar 26, 2012
@rspenc29 rspenc29 Added dragHold option to allow a user to keep hold of an overscrolled…
… element when the mouse moves away from it.
72c3553
Commits on Apr 12, 2012
@KingRial KingRial Modified overscroll to be compatible with all touch client without HT…
…ML5 css scrolling.

Simply added the touch events, a pageX pageY control using the first touch event as source, and a simple check to allow the recognition for a simple touch click event.

Tested on:
Android touch client version 2.3
iPhone 5.1
iPad 5.1
Chrome 18.xx
Firefox 12
363a56c
Jonathan Azoff Ignore intellij files 97369a8
Jonathan Azoff Explicit check for start element. Closes #48 e4a259b
Jonathan Azoff Merged in pull request #49. Added in support for draghold 9e88918
Jonathan Azoff Merge branch 'master' of github.com:KingRial/Overscroll into 1.6.2. M…
…erges #53 and Closes #51.

Conflicts:
	jquery.overscroll.js
ff58566
Jonathan Azoff Updated minified scripts and copy 72262a7
View
3  .gitignore
@@ -1 +1,2 @@
-.DS_Store
+.DS_Store
+.idea
View
53 README.md
@@ -1,11 +1,11 @@
-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).
Homepage: <http://azoffdesign.com/overscroll>
-
+
License
-------
Copyright 2012, Jonathan Azoff
@@ -34,10 +34,10 @@ $(selector).overscroll([options]);
- Start the overscrolled element at a particular left offset. Defers to the browser default if not set
* `options.scrollTop` `{Integer: undefined}`
- Start the overscrolled element at a particular top offset. Defers to the browser default if not set
- * `options.direction` `{String: 'auto'}`
+ * `options.direction` `{String: 'auto'}`
- The scroll direction of the overscrolled element, by default it will auto-detect the available directions. You can also restrict direction by setting this property equal to 'vertical' or 'horizontal'
* `options.cancelOn` `{String: ""}`
- - An optional jQuery selector to ignore on drag events. Note: must match an element inside the overscrolled element.
+ - An optional jQuery selector to ignore on drag events. Note: must match an element inside the overscrolled element.
* `options.wheelDirection` `{String: 'vertical'}`
- The direction scrolled when the mouse wheel is triggered. Options are 'horizontal' for left/right scrolling and 'vertical' for up/down scrolling.
* `options.wheelDelta` `{Number: 20}`
@@ -46,6 +46,8 @@ $(selector).overscroll([options]);
- The amount of drift to apply per drag interval
* `options.zIndex` `{Number: 999}`
- The z-index applied to the thumb elements
+ * `options.dragHold` `{Boolean: false}`
+ - Locks onto the overscrolled element when dragging and doesn't let go when the mouse moves away from it.
```javascript
$(selector).removeOverscroll();
@@ -75,13 +77,13 @@ Events
Apart from regular DOM events, overscrolled elements emit events to capture dragging and drifting boundaries. To listen to these events, simply listen for one of the following events on an overscrolled element:
+ `overscroll:dragstart`
- * The beginning of the drag event, happens when a user drags the overscrolled elemnent
+ * The beginning of the drag event, happens when a user drags the overscrolled elemnent
+ `overscroll:dragend`
- * The end of the drag event, happens after the drag, but before the drift
+ * The end of the drag event, happens after the drag, but before the drift
+ `overscroll:driftstart`
- * Happens right after `overscroll:dragend`, but only if the drag had enough inertia
+ * Happens right after `overscroll:dragend`, but only if the drag had enough inertia
+ `overscroll:driftend`
- * The end of a drift, happens after the drift effect completes
+ * The end of a drift, happens after the drift effect completes
Here is an example using jQuery's [on()](http://api.jquery.com/on/) method, listening for drag start:
@@ -101,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>
@@ -154,32 +163,32 @@ Change Log
- Added a z-index to the thumb CSS
* __1.4.6__
- Fixed regression in direction restriction
- + <https://github.com/azoff/Overscroll/issues/23>
+ + <https://github.com/azoff/Overscroll/issues/23>
- Added click insulation on drag events
- + <https://github.com/azoff/Overscroll/issues/22>
+ + <https://github.com/azoff/Overscroll/issues/22>
- Fixed bug when calculating container scrollWidth/Height (thanks Riccardo "Rial" Re)
* __1.4.5__
- Changed compiler to uglifyjs
- + <https://github.com/mishoo/UglifyJS>
+ + <https://github.com/mishoo/UglifyJS>
- Took advantage of `noop` shortcut
- Applied first git tag (1.4.5)
- Merged drift fix (thanks esseb)
- + <https://github.com/esseb/Overscroll/commit/8570a3cb564bbf7943c33cc6483036f1a7d8d81e>
+ + <https://github.com/esseb/Overscroll/commit/8570a3cb564bbf7943c33cc6483036f1a7d8d81e>
* __1.4.4__
- Maintain state on elements that have a pre-existing scroll offset
- Added deconstructor `jQuery.fn.removeOverscroll`
* __1.4.3__
- Improved iOS detection algorithm
- Fixed a typo in README.md
- + <https://github.com/azoff/Overscroll/issues/14>
+ + <https://github.com/azoff/Overscroll/issues/14>
- Removed 'onDriftEnd' and added real events
- + <https://github.com/azoff/Overscroll/issues/13>
+ + <https://github.com/azoff/Overscroll/issues/13>
* __1.4.2__
- Fixed bug in chrome due to ambiguous positioning
- Added the cancelOn option (thanks Herhor)
- + <https://github.com/azoff/Overscroll/issues/5>
+ + <https://github.com/azoff/Overscroll/issues/5>
- Fixed iOS start handler bug (thanks kkriehl)
- + <https://github.com/azoff/Overscroll/issues/9>
+ + <https://github.com/azoff/Overscroll/issues/9>
- Added Opera support
* __1.4.1__
- Fixed a null pointer exception that occurs when thumbs are hidden (thanks Henning)
@@ -189,23 +198,23 @@ Change Log
- Fixed bug with scroll event binding when no thumbs are present
- Improved drift mechanism by using a native animation over jQuery
- Added iOS support (thanks to Riccardo "Rial" Re)
- + <http://github.com/azoff/Overscroll/issues/7>
+ + <http://github.com/azoff/Overscroll/issues/7>
* __1.3.5__
- Added the ability to toggle mouse wheel scroll direction via options.wheelDirection (thanks Volderr)
- + <http://github.com/azoff/Overscroll/issues/4>
+ + <http://github.com/azoff/Overscroll/issues/4>
- Fixed bug with mouse wheel scroll direction (thanks Volderr)
- Cached the cursor CSS
* __1.3.4__
- Added the ability to call a function at the end of the drift via options.onDriftEnd
- + <http://github.com/azoff/Overscroll/issues/4> (thanks Volderr)
+ + <http://github.com/azoff/Overscroll/issues/4> (thanks Volderr)
* __1.3.3__
- Added the ability to control the drift delta (drift strength per scroll tick) via options.[wheel|scroll]Delta
- + <http://github.com/azoff/Overscroll/issues/3> (thanks Volderr)
+ + <http://github.com/azoff/Overscroll/issues/3> (thanks Volderr)
- Made mouse wheel scrolling more efficient via deferred fade out call
* __1.3.2__
- Updated documentation, added README file for Github
- Fixed undefined error on mouse wheel scroll for horizontal scrollers.
- + <http://github.com/azoff/Overscroll/issues/1> (thanks Volderr)
+ + <http://github.com/azoff/Overscroll/issues/1> (thanks Volderr)
- Added the ability to restrict scroll direction via options.direction
* __1.3.1__
- Made the dragging state externally visible via .data("dragging")
View
207 jquery.overscroll.js
@@ -1,5 +1,5 @@
/**
- * Overscroll v1.6.1
+ * Overscroll v1.6.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: Saturday, February 18th 2012
+ * Date: Thursday, April 12th 2012
*/
/*jslint onevar: true, strict: true */
@@ -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,32 +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;
+
// 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/';
@@ -74,19 +81,19 @@
}
return compat;
})(),
-
+
// These are all the events that could possibly
// be used by the plug-in
events = {
- drag: 'mousemove',
- end: 'mouseup mouseleave click',
+ drag: 'mousemove touchmove',
+ end: 'mouseup mouseleave click touchend touchcancel',
hover: 'mouseenter mouseleave',
ignored: 'select dragstart drag',
scroll: 'scroll',
- start: 'mousedown',
+ start: 'mousedown touchstart',
wheel: 'mousewheel DOMMouseScroll'
},
-
+
// These settings are used to tweak drift settings
// for the plug-in
settings = {
@@ -100,12 +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,
hoverThumbs: false,
scrollDelta: settings.scrollDelta,
showThumbs: true,
@@ -114,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
@@ -136,7 +144,7 @@
position.index = index;
return position;
},
-
+
// Used to move the thumbs around an overscrolled element
moveThumbs = function (thumbs, sizing, left, top) {
@@ -156,7 +164,7 @@
}
},
-
+
// Used to toggle the thumbs on and off
// of an overscrolled element
toggleThumbs = function (thumbs, options, dragging) {
@@ -178,14 +186,14 @@
}
}
},
-
+
// Defers click event listeners to after a mouseup event.
// Used to avoid unintentional clicks
deferClick = function (target) {
var events = target.data('events'),
click = events && events.click ? events.click.slice() : [];
if (events) { delete events.click; }
- target.one('mouseup', function () {
+ target.one('mouseup touchend touchcancel', function () {
$.each(click, function(i, event){
target.click(event);
});
@@ -211,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,
@@ -243,7 +251,7 @@
data.wheel = wheel = { timeout: null };
toggleThumbs(thumbs, options, true);
}
-
+
// actually modify scroll offsets
if (options.wheelDirection === 'horizontal') {
this.scrollLeft -= delta;
@@ -267,12 +275,20 @@
event.preventDefault();
- var data = event.data,
+ var data = event.data,
+ touches = event.originalEvent.touches,
options = data.options,
- sizing = data.sizing,
+ sizing = data.sizing,
thumbs = data.thumbs,
position = data.position,
- flags = data.flags;
+ flags = data.flags,
+ 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);
@@ -281,11 +297,11 @@
flags.dragged = true;
if (options.direction !== 'vertical') {
- this.scrollLeft -= (event.pageX - position.x);
+ target.scrollLeft -= (event.pageX - position.x);
}
if (data.options.direction !== 'horizontal') {
- this.scrollTop -= (event.pageY - position.y);
+ target.scrollTop -= (event.pageY - position.y);
}
capturePosition(event, data.position);
@@ -294,11 +310,11 @@
data.target.data(datakey).dragging = flags.dragging = true;
capturePosition(event, data.capture, settings.captureThreshold);
}
-
- moveThumbs(thumbs, sizing, this.scrollLeft, this.scrollTop);
+
+ moveThumbs(thumbs, sizing, target.scrollLeft, target.scrollTop);
},
-
+
// sends the overscrolled element into a drift
drift = function (target, event, callback) {
@@ -317,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;
@@ -361,7 +377,7 @@
});
},
-
+
// starts the drag operation and binds the mouse move handler
start = function (event) {
@@ -374,11 +390,23 @@
flags.drifting = false;
// only start drag if the user has not explictly banned it.
- if (!start.is(data.options.cancelOn)) {
- 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;
- target.on(events.drag, data, drag);
+
+ // 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);
@@ -394,7 +422,7 @@
options = data.options,
flags = data.flags,
thumbs = data.thumbs,
-
+
// hides the thumbs after the animation is done
done = function () {
if (thumbs && !options.hoverThumbs) {
@@ -402,7 +430,12 @@
}
};
- target.unbind(events.drag, drag);
+ // remove drag listeners from doc or target
+ if(options.dragHold) {
+ $(document).unbind(events.drag, drag);
+ } else {
+ target.unbind(events.drag, drag);
+ }
// only fire events and drift if we started with a
// valid position
@@ -412,19 +445,19 @@
// only drift if a drag passed our threshold
if (flags.dragging) {
- drift(this, event, done);
+ drift(target.get(0), event, done);
} 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 =
@@ -437,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;
@@ -453,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) {
@@ -471,7 +504,7 @@
height = $target.height(),
scrollWidth = width >= target.scrollWidth ? width : target.scrollWidth,
scrollHeight = height >= target.scrollHeight ? height : target.scrollHeight;
-
+
return {
container: {
width: width,
@@ -498,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'),
@@ -518,7 +551,7 @@
} else {
$target.removeAttr('style');
}
-
+
// remove any created thumbs
if (thumbs) {
if (thumbs.horizontal) { thumbs.horizontal.remove(); }
@@ -532,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) {
@@ -553,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);
@@ -573,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 = {
@@ -591,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({
@@ -603,15 +636,21 @@
.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);
}
-
+
// add thumbs and listeners (if we're showing them)
if (options.showThumbs) {
data.thumbs = thumbs = createThumbs(target, sizing, options);
@@ -622,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
@@ -642,19 +681,19 @@
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
// it
- touchscroll = function(options) {
+ touchscroll = function() {
return this.removeOverscroll().each(function() {
$(this).data(datakey, { remover: getRemover(this) })
.css(compat.overflowScrolling, 'touch')
.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
@@ -663,10 +702,10 @@
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
@@ -674,5 +713,5 @@
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",

No commit comments for this range

Something went wrong with that request. Please try again.