Permalink
Browse files

Update to v1.7.2

Added Bower Support #89
Added headless browser support #90
  • Loading branch information...
1 parent e707b75 commit 255d9153a2eecf9d1c30c884f7307f607ff4b54a @joshweinstein joshweinstein committed with Jonathan Azoff Mar 17, 2013
Showing with 21 additions and 7 deletions.
  1. +2 −2 README.md
  2. +7 −0 component.json
  3. +9 −2 jquery.overscroll.js
  4. +2 −2 jquery.overscroll.min.js
  5. +1 −1 overscroll.jquery.json
View
4 README.md
@@ -1,6 +1,6 @@
-Overscroll v1.7.1
+Overscroll v1.7.2
=================
-Monday, February 4th 2013
+Monday, March 18th 2013
Overscroll is a jQuery Plugin and [polyfill](http://remysharp.com/2010/10/08/what-is-a-polyfill) for mobile safari's [overflow-scrolling](http://johanbrook.com/browsers/native-momentum-scrolling-ios-5/) style. It is intended for use on desktop browsers, with [the latest version of jQuery](http://code.jquery.com/jquery-latest.js).
View
7 component.json
@@ -0,0 +1,7 @@
+{
+ "name": "jquery-overscroll",
+ "version": "1.7.2",
+ "dependencies": {
+ "jquery": null
+ }
+}
View
11 jquery.overscroll.js
@@ -1,5 +1,5 @@
/**
- * Overscroll v1.7.1
+ * Overscroll v1.7.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: Monday, February 4th 2013
+ * Date: Tuesday, March 18th 2013
*/
(function(global, dom, browser, math, wait, cancel, namespace, $, none){
@@ -24,6 +24,13 @@
// The key used to bind-instance specific data to an object
var datakey = 'overscroll';
+ // create <body> node if there's not one present (e.g., for test runners)
+ if (dom.body === null) {
+ dom.documentElement.appendChild(
+ dom.createElement('body')
+ );
+ }
+
// runs feature detection for overscroll
var compat = {
animate: (function(){
View
4 jquery.overscroll.min.js
@@ -1,2 +1,2 @@
-/* Overscroll 1.7.1 | azoffdesign.com/overscroll */
-(function(global,dom,browser,math,wait,cancel,namespace,$,none){"use strict";var datakey="overscroll";var compat={animate:function(){var fn=global.requestAnimationFrame||global.webkitRequestAnimationFrame||global.mozRequestAnimationFrame||global.oRequestAnimationFrame||global.msRequestAnimationFrame||function(callback){wait(callback,1e3/60)};return function(callback){fn.call(global,callback)}}(),overflowScrolling:function(){var style="";var div=dom.createElement("div");var prefixes=["webkit","moz","o","ms"];dom.body.appendChild(div);$.each(prefixes,function(i,prefix){div.style[prefix+"OverflowScrolling"]="touch"});div.style.overflowScrolling="touch";var computedStyle=global.getComputedStyle(div);if(!!computedStyle.overflowScrolling){style="overflow-scrolling"}else{$.each(prefixes,function(i,prefix){if(!!computedStyle[prefix+"OverflowScrolling"]){style="-"+prefix+"-overflow-scrolling"}return!style})}div.parentNode.removeChild(div);return style}(),cursor:function(){var div=dom.createElement("div");var prefixes=["webkit","moz"];var gmail="https://mail.google.com/mail/images/2/";var style={grab:"url("+gmail+"openhand.cur), move",grabbing:"url("+gmail+"closedhand.cur), move"};dom.body.appendChild(div);$.each(prefixes,function(i,prefix){var found,cursor="-"+prefix+"-grab";div.style.cursor=cursor;var computedStyle=global.getComputedStyle(div);found=computedStyle.cursor===cursor;if(found){style={grab:"-"+prefix+"-grab",grabbing:"-"+prefix+"-grabbing"}}return!found});div.parentNode.removeChild(div);return style}()};var events={drag:"mousemove touchmove",end:"mouseup mouseleave click touchend touchcancel",hover:"mouseenter mouseleave",ignored:"select dragstart drag",scroll:"scroll",start:"mousedown touchstart",wheel:"mousewheel DOMMouseScroll"};var settings={captureThreshold:3,driftDecay:1.1,driftSequences:22,driftTimeout:100,scrollDelta:15,thumbOpacity:.7,thumbThickness:6,thumbTimeout:400,wheelDelta:20,wheelTicks:120};var defaults={cancelOn:"select,input,textarea",direction:"multi",dragHold:false,hoverThumbs:false,scrollDelta:settings.scrollDelta,showThumbs:true,persistThumbs:false,captureWheel:true,wheelDelta:settings.wheelDelta,wheelDirection:"multi",zIndex:999};function triggerEvent(event,target){target.trigger("overscroll:"+event)}function time(){return(new Date).getTime()}function capturePosition(event,position,index){position.x=event.pageX;position.y=event.pageY;position.time=time();position.index=index;return position}function moveThumbs(thumbs,sizing,left,top){var ml,mt;if(thumbs&&thumbs.added){if(thumbs.horizontal){ml=left*(1+sizing.container.width/sizing.container.scrollWidth);mt=top+sizing.thumbs.horizontal.top;thumbs.horizontal.css("margin",mt+"px 0 0 "+ml+"px")}if(thumbs.vertical){ml=left+sizing.thumbs.vertical.left;mt=top*(1+sizing.container.height/sizing.container.scrollHeight);thumbs.vertical.css("margin",mt+"px 0 0 "+ml+"px")}}}function toggleThumbs(thumbs,options,dragging){if(thumbs&&thumbs.added&&!options.persistThumbs){if(dragging){if(thumbs.vertical){thumbs.vertical.stop(true,true).fadeTo("fast",settings.thumbOpacity)}if(thumbs.horizontal){thumbs.horizontal.stop(true,true).fadeTo("fast",settings.thumbOpacity)}}else{if(thumbs.vertical){thumbs.vertical.fadeTo("fast",0)}if(thumbs.horizontal){thumbs.horizontal.fadeTo("fast",0)}}}}function deferClick(target){var clicks,key="events";var events=$._data?$._data(target[0],key):target.data(key);if(events&&events.click){clicks=events.click.slice();target.off("click").one("click",function(){$.each(clicks,function(i,click){target.click(click)});return false})}}function hover(event){var data=event.data,thumbs=data.thumbs,options=data.options,dragging=event.type==="mouseenter";toggleThumbs(thumbs,options,dragging)}function scroll(event){var data=event.data;if(!data.flags.dragged){moveThumbs(data.thumbs,data.sizing,this.scrollLeft,this.scrollTop)}}function wheel(event){event.preventDefault();var data=event.data,options=data.options,sizing=data.sizing,thumbs=data.thumbs,dwheel=data.wheel,flags=data.flags,original=event.originalEvent,delta=0,deltaX=0,deltaY=0;flags.drifting=false;if(original.detail){delta=-original.detail;if(original.detailX){deltaX=-original.detailX}if(original.detailY){deltaY=-original.detailY}}else if(original.wheelDelta){delta=original.wheelDelta/settings.wheelTicks;if(original.wheelDeltaX){deltaX=original.wheelDeltaX/settings.wheelTicks}if(original.wheelDeltaY){deltaY=original.wheelDeltaY/settings.wheelTicks}}delta*=options.wheelDelta;deltaX*=options.wheelDelta;deltaY*=options.wheelDelta;if(!dwheel){data.target.data(datakey).dragging=flags.dragging=true;data.wheel=dwheel={timeout:null};toggleThumbs(thumbs,options,true)}if(options.wheelDirection==="vertical"){this.scrollTop-=delta}else if(options.wheelDirection==="horizontal"){this.scrollLeft-=delta}else{this.scrollLeft-=deltaX;this.scrollTop-=deltaY||delta}if(dwheel.timeout){cancel(dwheel.timeout)}moveThumbs(thumbs,sizing,this.scrollLeft,this.scrollTop);dwheel.timeout=wait(function(){data.target.data(datakey).dragging=flags.dragging=false;toggleThumbs(thumbs,options,data.wheel=null)},settings.thumbTimeout)}function drag(event){event.preventDefault();var data=event.data,touches=event.originalEvent.touches,options=data.options,sizing=data.sizing,thumbs=data.thumbs,position=data.position,flags=data.flags,target=data.target.get(0);if(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}if(data.options.direction!=="horizontal"){target.scrollTop-=event.pageY-position.y}capturePosition(event,data.position);if(--data.capture.index<=0){data.target.data(datakey).dragging=flags.dragging=true;capturePosition(event,data.capture,settings.captureThreshold)}moveThumbs(thumbs,sizing,target.scrollLeft,target.scrollTop)}function drift(target,event,callback){var data=event.data,dx,dy,xMod,yMod,capture=data.capture,options=data.options,sizing=data.sizing,thumbs=data.thumbs,elapsed=time()-capture.time,scrollLeft=target.scrollLeft,scrollTop=target.scrollTop,decay=settings.driftDecay;if(elapsed>settings.driftTimeout){callback(data);return}dx=options.scrollDelta*(event.pageX-capture.x);dy=options.scrollDelta*(event.pageY-capture.y);if(options.direction!=="vertical"){scrollLeft-=dx}if(options.direction!=="horizontal"){scrollTop-=dy}xMod=dx/settings.driftSequences;yMod=dy/settings.driftSequences;triggerEvent("driftstart",data.target);data.drifting=true;compat.animate(function render(){if(data.drifting){var min=1,max=-1;data.drifting=false;if(yMod>min&&target.scrollTop>scrollTop||yMod<max&&target.scrollTop<scrollTop){data.drifting=true;target.scrollTop-=yMod;yMod/=decay}if(xMod>min&&target.scrollLeft>scrollLeft||xMod<max&&target.scrollLeft<scrollLeft){data.drifting=true;target.scrollLeft-=xMod;xMod/=decay}moveThumbs(thumbs,sizing,target.scrollLeft,target.scrollTop);compat.animate(render)}else{triggerEvent("driftend",data.target);callback(data)}})}function start(event){var data=event.data,touches=event.originalEvent.touches,target=data.target,dstart=data.start=$(event.target),flags=data.flags;flags.drifting=false;if(dstart.size()&&!dstart.is(data.options.cancelOn)){if(!touches){event.preventDefault()}if(!compat.overflowScrolling){target.css("cursor",compat.cursor.grabbing);target.data(datakey).dragging=flags.dragging=flags.dragged=false;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)}}function stop(event){var data=event.data,target=data.target,options=data.options,flags=data.flags,thumbs=data.thumbs,done=function(){if(thumbs&&!options.hoverThumbs){toggleThumbs(thumbs,options,false)}};if(options.dragHold){$(document).unbind(events.drag,drag)}else{target.unbind(events.drag,drag)}if(data.position){triggerEvent("dragend",target);if(flags.dragging&&!compat.overflowScrolling){drift(target.get(0),event,done)}else{done()}}if(flags.dragging&&!compat.overflowScrolling&&data.start&&data.start.is(event.target)){deferClick(data.start)}target.data(datakey).dragging=data.start=data.capture=data.position=flags.dragged=flags.dragging=false;target.css("cursor",compat.cursor.grab)}function getOptions(options){options=$.extend({},defaults,options);if(options.direction!=="multi"&&options.direction!==options.wheelDirection){options.wheelDirection=options.direction}options.scrollDelta=math.abs(parseFloat(options.scrollDelta));options.wheelDelta=math.abs(parseFloat(options.wheelDelta));options.scrollLeft=options.scrollLeft===none?null:math.abs(parseFloat(options.scrollLeft));options.scrollTop=options.scrollTop===none?null:math.abs(parseFloat(options.scrollTop));return options}function getSizing(target){var $target=$(target),width=$target.width(),height=$target.height(),scrollWidth=width>=target.scrollWidth?width:target.scrollWidth,scrollHeight=height>=target.scrollHeight?height:target.scrollHeight,hasScroll=scrollWidth>width||scrollHeight>height;return{valid:hasScroll,container:{width:width,height:height,scrollWidth:scrollWidth,scrollHeight:scrollHeight},thumbs:{horizontal:{width:width*width/scrollWidth,height:settings.thumbThickness,corner:settings.thumbThickness/2,left:0,top:height-settings.thumbThickness},vertical:{width:settings.thumbThickness,height:height*height/scrollHeight,corner:settings.thumbThickness/2,left:width-settings.thumbThickness,top:0}}}}function getRemover(target,orCreate){var $target=$(target),thumbs,data=$target.data(datakey)||{},style=$target.attr("style"),fallback=orCreate?function(){data=$target.data(datakey);thumbs=data.thumbs;if(style){$target.attr("style",style)}else{$target.removeAttr("style")}if(thumbs){if(thumbs.horizontal){thumbs.horizontal.remove()}if(thumbs.vertical){thumbs.vertical.remove()}}$target.removeData(datakey).off(events.wheel,wheel).off(events.start,start).off(events.end,stop).off(events.ignored,ignore)}:$.noop;return $.isFunction(data.remover)?data.remover:fallback}function getThumbCss(size,options){return{position:"absolute",opacity:options.persistThumbs?settings.thumbOpacity:0,"background-color":"black",width:size.width+"px",height:size.height+"px","border-radius":size.corner+"px",margin:size.top+"px 0 0 "+size.left+"px","z-index":options.zIndex}}function createThumbs(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)}if(sizing.container.scrollHeight>0&&options.direction!=="horizontal"){css=getThumbCss(sizing.thumbs.vertical,options);thumbs.vertical=$(div).css(css).prependTo(target)}thumbs.added=!!css;return thumbs}function ignore(event){event.preventDefault()}function setup(target,options){options=getOptions(options);var sizing=getSizing(target),thumbs,data={options:options,sizing:sizing,flags:{dragging:false},remover:getRemover(target,true)};if(sizing.valid){data.target=target=$(target).css({position:"relative",cursor:compat.cursor.grab}).on(events.start,data,start).on(events.end,data,stop).on(events.ignored,data,ignore);if(options.dragHold){$(document).on(events.end,data,stop)}else{data.target.on(events.end,data,stop)}if(options.scrollLeft!==null){target.scrollLeft(options.scrollLeft)}if(options.scrollTop!==null){target.scrollTop(options.scrollTop)}if(compat.overflowScrolling){target.css(compat.overflowScrolling,"touch")}else{target.on(events.scroll,data,scroll)}if(options.captureWheel){target.on(events.wheel,data,wheel)}if(options.showThumbs){if(compat.overflowScrolling){target.css("overflow","scroll")}else{target.css("overflow","hidden");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)}}}}else{target.css("overflow","hidden")}target.data(datakey,data)}}function teardown(target){getRemover(target)()}function overscroll(options){return this.removeOverscroll().each(function(){setup(this,options)})}function removeOverscroll(){return this.each(function(){teardown(this)})}overscroll.settings=settings;$.extend(namespace,{overscroll:overscroll,removeOverscroll:removeOverscroll})})(window,document,navigator,Math,setTimeout,clearTimeout,jQuery.fn,jQuery);
+/* Overscroll 1.7.2 | azoffdesign.com/overscroll */
+(function(global,dom,browser,math,wait,cancel,namespace,$,none){"use strict";var datakey="overscroll";if(dom.body===null){dom.documentElement.appendChild(dom.createElement("body"))}var compat={animate:function(){var fn=global.requestAnimationFrame||global.webkitRequestAnimationFrame||global.mozRequestAnimationFrame||global.oRequestAnimationFrame||global.msRequestAnimationFrame||function(callback){wait(callback,1e3/60)};return function(callback){fn.call(global,callback)}}(),overflowScrolling:function(){var style="";var div=dom.createElement("div");var prefixes=["webkit","moz","o","ms"];dom.body.appendChild(div);$.each(prefixes,function(i,prefix){div.style[prefix+"OverflowScrolling"]="touch"});div.style.overflowScrolling="touch";var computedStyle=global.getComputedStyle(div);if(!!computedStyle.overflowScrolling){style="overflow-scrolling"}else{$.each(prefixes,function(i,prefix){if(!!computedStyle[prefix+"OverflowScrolling"]){style="-"+prefix+"-overflow-scrolling"}return!style})}div.parentNode.removeChild(div);return style}(),cursor:function(){var div=dom.createElement("div");var prefixes=["webkit","moz"];var gmail="https://mail.google.com/mail/images/2/";var style={grab:"url("+gmail+"openhand.cur), move",grabbing:"url("+gmail+"closedhand.cur), move"};dom.body.appendChild(div);$.each(prefixes,function(i,prefix){var found,cursor="-"+prefix+"-grab";div.style.cursor=cursor;var computedStyle=global.getComputedStyle(div);found=computedStyle.cursor===cursor;if(found){style={grab:"-"+prefix+"-grab",grabbing:"-"+prefix+"-grabbing"}}return!found});div.parentNode.removeChild(div);return style}()};var events={drag:"mousemove touchmove",end:"mouseup mouseleave click touchend touchcancel",hover:"mouseenter mouseleave",ignored:"select dragstart drag",scroll:"scroll",start:"mousedown touchstart",wheel:"mousewheel DOMMouseScroll"};var settings={captureThreshold:3,driftDecay:1.1,driftSequences:22,driftTimeout:100,scrollDelta:15,thumbOpacity:.7,thumbThickness:6,thumbTimeout:400,wheelDelta:20,wheelTicks:120};var defaults={cancelOn:"select,input,textarea",direction:"multi",dragHold:false,hoverThumbs:false,scrollDelta:settings.scrollDelta,showThumbs:true,persistThumbs:false,captureWheel:true,wheelDelta:settings.wheelDelta,wheelDirection:"multi",zIndex:999};function triggerEvent(event,target){target.trigger("overscroll:"+event)}function time(){return(new Date).getTime()}function capturePosition(event,position,index){position.x=event.pageX;position.y=event.pageY;position.time=time();position.index=index;return position}function moveThumbs(thumbs,sizing,left,top){var ml,mt;if(thumbs&&thumbs.added){if(thumbs.horizontal){ml=left*(1+sizing.container.width/sizing.container.scrollWidth);mt=top+sizing.thumbs.horizontal.top;thumbs.horizontal.css("margin",mt+"px 0 0 "+ml+"px")}if(thumbs.vertical){ml=left+sizing.thumbs.vertical.left;mt=top*(1+sizing.container.height/sizing.container.scrollHeight);thumbs.vertical.css("margin",mt+"px 0 0 "+ml+"px")}}}function toggleThumbs(thumbs,options,dragging){if(thumbs&&thumbs.added&&!options.persistThumbs){if(dragging){if(thumbs.vertical){thumbs.vertical.stop(true,true).fadeTo("fast",settings.thumbOpacity)}if(thumbs.horizontal){thumbs.horizontal.stop(true,true).fadeTo("fast",settings.thumbOpacity)}}else{if(thumbs.vertical){thumbs.vertical.fadeTo("fast",0)}if(thumbs.horizontal){thumbs.horizontal.fadeTo("fast",0)}}}}function deferClick(target){var clicks,key="events";var events=$._data?$._data(target[0],key):target.data(key);if(events&&events.click){clicks=events.click.slice();target.off("click").one("click",function(){$.each(clicks,function(i,click){target.click(click)});return false})}}function hover(event){var data=event.data,thumbs=data.thumbs,options=data.options,dragging=event.type==="mouseenter";toggleThumbs(thumbs,options,dragging)}function scroll(event){var data=event.data;if(!data.flags.dragged){moveThumbs(data.thumbs,data.sizing,this.scrollLeft,this.scrollTop)}}function wheel(event){event.preventDefault();var data=event.data,options=data.options,sizing=data.sizing,thumbs=data.thumbs,dwheel=data.wheel,flags=data.flags,original=event.originalEvent,delta=0,deltaX=0,deltaY=0;flags.drifting=false;if(original.detail){delta=-original.detail;if(original.detailX){deltaX=-original.detailX}if(original.detailY){deltaY=-original.detailY}}else if(original.wheelDelta){delta=original.wheelDelta/settings.wheelTicks;if(original.wheelDeltaX){deltaX=original.wheelDeltaX/settings.wheelTicks}if(original.wheelDeltaY){deltaY=original.wheelDeltaY/settings.wheelTicks}}delta*=options.wheelDelta;deltaX*=options.wheelDelta;deltaY*=options.wheelDelta;if(!dwheel){data.target.data(datakey).dragging=flags.dragging=true;data.wheel=dwheel={timeout:null};toggleThumbs(thumbs,options,true)}if(options.wheelDirection==="vertical"){this.scrollTop-=delta}else if(options.wheelDirection==="horizontal"){this.scrollLeft-=delta}else{this.scrollLeft-=deltaX;this.scrollTop-=deltaY||delta}if(dwheel.timeout){cancel(dwheel.timeout)}moveThumbs(thumbs,sizing,this.scrollLeft,this.scrollTop);dwheel.timeout=wait(function(){data.target.data(datakey).dragging=flags.dragging=false;toggleThumbs(thumbs,options,data.wheel=null)},settings.thumbTimeout)}function drag(event){event.preventDefault();var data=event.data,touches=event.originalEvent.touches,options=data.options,sizing=data.sizing,thumbs=data.thumbs,position=data.position,flags=data.flags,target=data.target.get(0);if(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}if(data.options.direction!=="horizontal"){target.scrollTop-=event.pageY-position.y}capturePosition(event,data.position);if(--data.capture.index<=0){data.target.data(datakey).dragging=flags.dragging=true;capturePosition(event,data.capture,settings.captureThreshold)}moveThumbs(thumbs,sizing,target.scrollLeft,target.scrollTop)}function drift(target,event,callback){var data=event.data,dx,dy,xMod,yMod,capture=data.capture,options=data.options,sizing=data.sizing,thumbs=data.thumbs,elapsed=time()-capture.time,scrollLeft=target.scrollLeft,scrollTop=target.scrollTop,decay=settings.driftDecay;if(elapsed>settings.driftTimeout){callback(data);return}dx=options.scrollDelta*(event.pageX-capture.x);dy=options.scrollDelta*(event.pageY-capture.y);if(options.direction!=="vertical"){scrollLeft-=dx}if(options.direction!=="horizontal"){scrollTop-=dy}xMod=dx/settings.driftSequences;yMod=dy/settings.driftSequences;triggerEvent("driftstart",data.target);data.drifting=true;compat.animate(function render(){if(data.drifting){var min=1,max=-1;data.drifting=false;if(yMod>min&&target.scrollTop>scrollTop||yMod<max&&target.scrollTop<scrollTop){data.drifting=true;target.scrollTop-=yMod;yMod/=decay}if(xMod>min&&target.scrollLeft>scrollLeft||xMod<max&&target.scrollLeft<scrollLeft){data.drifting=true;target.scrollLeft-=xMod;xMod/=decay}moveThumbs(thumbs,sizing,target.scrollLeft,target.scrollTop);compat.animate(render)}else{triggerEvent("driftend",data.target);callback(data)}})}function start(event){var data=event.data,touches=event.originalEvent.touches,target=data.target,dstart=data.start=$(event.target),flags=data.flags;flags.drifting=false;if(dstart.size()&&!dstart.is(data.options.cancelOn)){if(!touches){event.preventDefault()}if(!compat.overflowScrolling){target.css("cursor",compat.cursor.grabbing);target.data(datakey).dragging=flags.dragging=flags.dragged=false;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)}}function stop(event){var data=event.data,target=data.target,options=data.options,flags=data.flags,thumbs=data.thumbs,done=function(){if(thumbs&&!options.hoverThumbs){toggleThumbs(thumbs,options,false)}};if(options.dragHold){$(document).unbind(events.drag,drag)}else{target.unbind(events.drag,drag)}if(data.position){triggerEvent("dragend",target);if(flags.dragging&&!compat.overflowScrolling){drift(target.get(0),event,done)}else{done()}}if(flags.dragging&&!compat.overflowScrolling&&data.start&&data.start.is(event.target)){deferClick(data.start)}target.data(datakey).dragging=data.start=data.capture=data.position=flags.dragged=flags.dragging=false;target.css("cursor",compat.cursor.grab)}function getOptions(options){options=$.extend({},defaults,options);if(options.direction!=="multi"&&options.direction!==options.wheelDirection){options.wheelDirection=options.direction}options.scrollDelta=math.abs(parseFloat(options.scrollDelta));options.wheelDelta=math.abs(parseFloat(options.wheelDelta));options.scrollLeft=options.scrollLeft===none?null:math.abs(parseFloat(options.scrollLeft));options.scrollTop=options.scrollTop===none?null:math.abs(parseFloat(options.scrollTop));return options}function getSizing(target){var $target=$(target),width=$target.width(),height=$target.height(),scrollWidth=width>=target.scrollWidth?width:target.scrollWidth,scrollHeight=height>=target.scrollHeight?height:target.scrollHeight,hasScroll=scrollWidth>width||scrollHeight>height;return{valid:hasScroll,container:{width:width,height:height,scrollWidth:scrollWidth,scrollHeight:scrollHeight},thumbs:{horizontal:{width:width*width/scrollWidth,height:settings.thumbThickness,corner:settings.thumbThickness/2,left:0,top:height-settings.thumbThickness},vertical:{width:settings.thumbThickness,height:height*height/scrollHeight,corner:settings.thumbThickness/2,left:width-settings.thumbThickness,top:0}}}}function getRemover(target,orCreate){var $target=$(target),thumbs,data=$target.data(datakey)||{},style=$target.attr("style"),fallback=orCreate?function(){data=$target.data(datakey);thumbs=data.thumbs;if(style){$target.attr("style",style)}else{$target.removeAttr("style")}if(thumbs){if(thumbs.horizontal){thumbs.horizontal.remove()}if(thumbs.vertical){thumbs.vertical.remove()}}$target.removeData(datakey).off(events.wheel,wheel).off(events.start,start).off(events.end,stop).off(events.ignored,ignore)}:$.noop;return $.isFunction(data.remover)?data.remover:fallback}function getThumbCss(size,options){return{position:"absolute",opacity:options.persistThumbs?settings.thumbOpacity:0,"background-color":"black",width:size.width+"px",height:size.height+"px","border-radius":size.corner+"px",margin:size.top+"px 0 0 "+size.left+"px","z-index":options.zIndex}}function createThumbs(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)}if(sizing.container.scrollHeight>0&&options.direction!=="horizontal"){css=getThumbCss(sizing.thumbs.vertical,options);thumbs.vertical=$(div).css(css).prependTo(target)}thumbs.added=!!css;return thumbs}function ignore(event){event.preventDefault()}function setup(target,options){options=getOptions(options);var sizing=getSizing(target),thumbs,data={options:options,sizing:sizing,flags:{dragging:false},remover:getRemover(target,true)};if(sizing.valid){data.target=target=$(target).css({position:"relative",cursor:compat.cursor.grab}).on(events.start,data,start).on(events.end,data,stop).on(events.ignored,data,ignore);if(options.dragHold){$(document).on(events.end,data,stop)}else{data.target.on(events.end,data,stop)}if(options.scrollLeft!==null){target.scrollLeft(options.scrollLeft)}if(options.scrollTop!==null){target.scrollTop(options.scrollTop)}if(compat.overflowScrolling){target.css(compat.overflowScrolling,"touch")}else{target.on(events.scroll,data,scroll)}if(options.captureWheel){target.on(events.wheel,data,wheel)}if(options.showThumbs){if(compat.overflowScrolling){target.css("overflow","scroll")}else{target.css("overflow","hidden");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)}}}}else{target.css("overflow","hidden")}target.data(datakey,data)}}function teardown(target){getRemover(target)()}function overscroll(options){return this.removeOverscroll().each(function(){setup(this,options)})}function removeOverscroll(){return this.each(function(){teardown(this)})}overscroll.settings=settings;$.extend(namespace,{overscroll:overscroll,removeOverscroll:removeOverscroll})})(window,document,navigator,Math,setTimeout,clearTimeout,jQuery.fn,jQuery)
View
2 overscroll.jquery.json
@@ -1,6 +1,6 @@
{
"name": "overscroll",
- "version": "1.7.1",
+ "version": "1.7.2",
"title": "Overscroll",
"description": "Overscroll is a jQuery Plugin and polyfill for mobile safari's overflow-scrolling style. It is intended for use on desktop browsers.",
"keywords": ["ios", "iphone", "ipad", "retina", "scroll", "drift", "drag", "bounce", "overflow"],

0 comments on commit 255d915

Please sign in to comment.