This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/static/lib/jquery.overscroll.min.js

1 line
No EOL
8.5 KiB
JavaScript

!function(a,b,c,d,e,f,g,h,i){"use strict";function j(a,b){b.trigger("overscroll:"+a)}function k(){return(new Date).getTime()}function l(a,b,c){return b.x=a.pageX,b.y=a.pageY,b.time=k(),b.index=c,b}function m(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")))}function n(a,b,c){a&&a.added&&!b.persistThumbs&&(c?(a.vertical&&a.vertical.stop(!0,!0).fadeTo("fast",J.thumbOpacity),a.horizontal&&a.horizontal.stop(!0,!0).fadeTo("fast",J.thumbOpacity)):(a.vertical&&a.vertical.fadeTo("fast",0),a.horizontal&&a.horizontal.fadeTo("fast",0)))}function o(a){var b,c="events",d=h._data?h._data(a[0],c):a.data(c);d&&d.click&&(b=d.click.slice(),a.off("click").one("click",function(){return h.each(b,function(b,c){a.click(c)}),!1}))}function p(a){var b=a.data,c=b.thumbs,d=b.options,e="mouseenter"===a.type;n(c,d,e)}function q(a){var b=a.data;b.flags.dragged||m(b.thumbs,b.sizing,this.scrollLeft,this.scrollTop)}function r(a){a.preventDefault();var b=a.data,c=b.options,d=b.sizing,g=b.thumbs,h=b.wheel,i=b.flags,j=a.originalEvent,k=0,l=0,o=0;i.drifting=!1,j.detail?(k=-j.detail,j.detailX&&(l=-j.detailX),j.detailY&&(o=-j.detailY)):j.wheelDelta&&(k=j.wheelDelta/J.wheelTicks,j.wheelDeltaX&&(l=j.wheelDeltaX/J.wheelTicks),j.wheelDeltaY&&(o=j.wheelDeltaY/J.wheelTicks)),k*=c.wheelDelta,l*=c.wheelDelta,o*=c.wheelDelta,h||(b.target.data(G).dragging=i.dragging=!0,b.wheel=h={timeout:null},n(g,c,!0)),"vertical"===c.wheelDirection?this.scrollTop-=k:"horizontal"===c.wheelDirection?this.scrollLeft-=k:(this.scrollLeft-=l,this.scrollTop-=o||k),h.timeout&&f(h.timeout),m(g,d,this.scrollLeft,this.scrollTop),h.timeout=e(function(){b.target.data(G).dragging=i.dragging=!1,n(g,c,b.wheel=null)},J.thumbTimeout)}function s(a){a.preventDefault();var b=a.data,c=a.originalEvent.touches,d=b.options,e=b.sizing,f=b.thumbs,g=b.position,h=b.flags,i=b.target.get(0);c&&c.length&&(a=c[0]),h.dragged||n(f,d,!0),h.dragged=!0,"vertical"!==d.direction&&(i.scrollLeft-=a.pageX-g.x),"horizontal"!==b.options.direction&&(i.scrollTop-=a.pageY-g.y),l(a,b.position),--b.capture.index<=0&&(b.target.data(G).dragging=h.dragging=!0,l(a,b.capture,J.captureThreshold)),m(f,e,i.scrollLeft,i.scrollTop)}function t(a,b,c){var d,e,f,g,h=b.data,i=h.capture,l=h.options,n=h.sizing,o=h.thumbs,p=k()-i.time,q=a.scrollLeft,r=a.scrollTop,s=J.driftDecay;return p>J.driftTimeout?(c(h),void 0):(d=l.scrollDelta*(b.pageX-i.x),e=l.scrollDelta*(b.pageY-i.y),"vertical"!==l.direction&&(q-=d),"horizontal"!==l.direction&&(r-=e),f=d/J.driftSequences,g=e/J.driftSequences,j("driftstart",h.target),h.drifting=!0,H.animate(function t(){if(h.drifting){var b=1,d=-1;h.drifting=!1,(g>b&&a.scrollTop>r||d>g&&a.scrollTop<r)&&(h.drifting=!0,a.scrollTop-=g,g/=s),(f>b&&a.scrollLeft>q||d>f&&a.scrollLeft<q)&&(h.drifting=!0,a.scrollLeft-=f,f/=s),m(o,n,a.scrollLeft,a.scrollTop),H.animate(t)}else j("driftend",h.target),c(h)}),void 0)}function u(a){var b=a.data,c=a.originalEvent.touches,d=b.target,e=b.start=h(a.target),f=b.flags;f.drifting=!1,e.size()&&!e.is(b.options.cancelOn)&&(c||a.preventDefault(),H.overflowScrolling||(d.css("cursor",H.cursor.grabbing),d.data(G).dragging=f.dragging=f.dragged=!1,b.options.dragHold?h(document).on(I.drag,b,s):d.on(I.drag,b,s)),b.position=l(a,{}),b.capture=l(a,{},J.captureThreshold),j("dragstart",d))}function v(a){var b=a.data,c=b.target,d=b.options,e=b.flags,f=b.thumbs,g=function(){f&&!d.hoverThumbs&&n(f,d,!1)};d.dragHold?h(document).unbind(I.drag,s):c.unbind(I.drag,s),b.position&&(j("dragend",c),e.dragging&&!H.overflowScrolling?t(c.get(0),a,g):g()),e.dragging&&!H.overflowScrolling&&b.start&&b.start.is(a.target)&&o(b.start),c.data(G).dragging=b.start=b.capture=b.position=e.dragged=e.dragging=!1,c.css("cursor",H.cursor.grab)}function w(a){return a=h.extend({},K,a),"multi"!==a.direction&&a.direction!==a.wheelDirection&&(a.wheelDirection=a.direction),a.scrollDelta=d.abs(parseFloat(a.scrollDelta)),a.wheelDelta=d.abs(parseFloat(a.wheelDelta)),a.scrollLeft=a.scrollLeft===i?null:d.abs(parseFloat(a.scrollLeft)),a.scrollTop=a.scrollTop===i?null:d.abs(parseFloat(a.scrollTop)),a}function x(a){var b=h(a),c=b.width(),d=b.height(),e=c>=a.scrollWidth?c:a.scrollWidth,f=d>=a.scrollHeight?d:a.scrollHeight,g=e>c||f>d;return{valid:g,container:{width:c,height:d,scrollWidth:e,scrollHeight:f},thumbs:{horizontal:{width:c*c/e,height:J.thumbThickness,corner:J.thumbThickness/2,left:0,top:d-J.thumbThickness},vertical:{width:J.thumbThickness,height:d*d/f,corner:J.thumbThickness/2,left:c-J.thumbThickness,top:0}}}}function y(a,b){var c,d=h(a),e=d.data(G)||{},f=d.attr("style"),g=b?function(){e=d.data(G),c=e.thumbs,f?d.attr("style",f):d.removeAttr("style"),c&&(c.horizontal&&c.horizontal.remove(),c.vertical&&c.vertical.remove()),d.removeData(G).off(I.wheel,r).off(I.start,u).off(I.end,v).off(I.ignored,B)}:h.noop;return h.isFunction(e.remover)?e.remover:g}function z(a,b){return{position:"absolute",opacity:b.persistThumbs?J.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}}function A(a,b,c){var d="<div/>",e={},f=!1;return b.container.scrollWidth>0&&"vertical"!==c.direction&&(f=z(b.thumbs.horizontal,c),e.horizontal=h(d).css(f).prependTo(a)),b.container.scrollHeight>0&&"horizontal"!==c.direction&&(f=z(b.thumbs.vertical,c),e.vertical=h(d).css(f).prependTo(a)),e.added=!!f,e}function B(a){a.preventDefault()}function C(a,b){b=w(b);var c,d=x(a),e={options:b,sizing:d,flags:{dragging:!1},remover:y(a,!0)};(d.valid||b.ignoreSizing)&&(e.target=a=h(a).css({position:"relative",cursor:H.cursor.grab}).on(I.start,e,u).on(I.end,e,v).on(I.ignored,e,B),b.dragHold?h(document).on(I.end,e,v):e.target.on(I.end,e,v),null!==b.scrollLeft&&a.scrollLeft(b.scrollLeft),null!==b.scrollTop&&a.scrollTop(b.scrollTop),H.overflowScrolling?a.css(H.overflowScrolling,"touch"):a.on(I.scroll,e,q),b.captureWheel&&a.on(I.wheel,e,r),b.showThumbs?H.overflowScrolling?a.css("overflow","scroll"):(a.css("overflow","hidden"),e.thumbs=c=A(a,d,b),c.added&&(m(c,d,a.scrollLeft(),a.scrollTop()),b.hoverThumbs&&a.on(I.hover,e,p))):a.css("overflow","hidden"),a.data(G,e))}function D(a){y(a)()}function E(a){return this.removeOverscroll().each(function(){C(this,a)})}function F(){return this.each(function(){D(this)})}var G="overscroll";null===b.body&&b.documentElement.appendChild(b.createElement("body")),a.getComputedStyle||(a.getComputedStyle=function(a){return this.el=a,this.getPropertyValue=function(b){var c=/(\-([a-z]){1})/g;return"float"==b&&(b="styleFloat"),c.test(b)&&(b=b.replace(c,function(){return arguments[2].toUpperCase()})),a.currentStyle[b]?a.currentStyle[b]:null},this});var H={animate:function(){var b=a.requestAnimationFrame||a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame||a.msRequestAnimationFrame||function(a){e(a,1e3/60)};return function(c){b.call(a,c)}}(),overflowScrolling:function(){var c="",d=b.createElement("div"),e=["webkit","moz","o","ms"];b.body.appendChild(d),h.each(e,function(a,b){d.style[b+"OverflowScrolling"]="touch"}),d.style.overflowScrolling="touch";var f=a.getComputedStyle(d);return f.overflowScrolling?c="overflow-scrolling":h.each(e,function(a,b){return f[b+"OverflowScrolling"]&&(c="-"+b+"-overflow-scrolling"),!c}),d.parentNode.removeChild(d),c}(),cursor:function(){var c=b.createElement("div"),d=["webkit","moz"],e="https://mail.google.com/mail/images/2/",f={grab:"url("+e+"openhand.cur), move",grabbing:"url("+e+"closedhand.cur), move"};return b.body.appendChild(c),h.each(d,function(b,d){var e,g="-"+d+"-grab";c.style.cursor=g;var h=a.getComputedStyle(c);return e=h.cursor===g,e&&(f={grab:"-"+d+"-grab",grabbing:"-"+d+"-grabbing"}),!e}),c.parentNode.removeChild(c),f}()},I={drag:"mousemove touchmove",end:"mouseup mouseleave click touchend touchcancel",hover:"mouseenter mouseleave",ignored:"select dragstart drag",scroll:"scroll",start:"mousedown touchstart",wheel:"mousewheel DOMMouseScroll"},J={captureThreshold:3,driftDecay:1.1,driftSequences:22,driftTimeout:100,scrollDelta:15,thumbOpacity:.7,thumbThickness:6,thumbTimeout:400,wheelDelta:20,wheelTicks:120},K={cancelOn:"select,input,textarea",direction:"multi",dragHold:!1,hoverThumbs:!1,scrollDelta:J.scrollDelta,showThumbs:!0,persistThumbs:!1,captureWheel:!0,wheelDelta:J.wheelDelta,wheelDirection:"multi",zIndex:999,ignoreSizing:!1};E.settings=J,h.extend(g,{overscroll:E,removeOverscroll:F})}(window,document,navigator,Math,setTimeout,clearTimeout,jQuery.fn,jQuery);