15 lines
38 KiB
JavaScript
15 lines
38 KiB
JavaScript
|
/*!
|
||
|
* VERSION: 0.16.3
|
||
|
* DATE: 2018-05-04
|
||
|
* UPDATES AND DOCS AT: http://greensock.com
|
||
|
*
|
||
|
* Requires TweenLite and CSSPlugin version 1.17.0 or later (TweenMax contains both TweenLite and CSSPlugin). ThrowPropsPlugin is required for momentum-based continuation of movement after the mouse/touch is released (ThrowPropsPlugin is a membership benefit of Club GreenSock - http://greensock.com/club/).
|
||
|
*
|
||
|
* @license Copyright (c) 2008-2018, GreenSock. All rights reserved.
|
||
|
* This work is subject to the terms at http://greensock.com/standard-license or for
|
||
|
* Club GreenSock members, the software agreement that was issued with your membership.
|
||
|
*
|
||
|
* @author: Jack Doyle, jack@greensock.com
|
||
|
*/
|
||
|
var _gsScope="undefined"!=typeof module&&module.exports&&"undefined"!=typeof global?global:this||window;(_gsScope._gsQueue||(_gsScope._gsQueue=[])).push(function(){"use strict";_gsScope._gsDefine("utils.Draggable",["events.EventDispatcher","TweenLite","plugins.CSSPlugin"],function(a,b,c){var d,e,f,g,h,i,j,k,l={css:{},data:"_draggable"},m={css:{},data:"_draggable"},n={css:{},data:"_draggable"},o={css:{}},p=_gsScope._gsDefine.globals,q={},r={style:{}},s=_gsScope.document||{createElement:function(){return r}},t=s.documentElement||{},u=function(a){return s.createElementNS?s.createElementNS("http://www.w3.org/1999/xhtml",a):s.createElement(a)},v=u("div"),w=[],x=function(){return!1},y=180/Math.PI,z=999999999999999,A=Date.now||function(){return(new Date).getTime()},B=!(s.addEventListener||!s.all),C=s.createElement("div"),D=[],E={},F=0,G=/^(?:a|input|textarea|button|select)$/i,H=0,I=_gsScope.navigator&&-1!==_gsScope.navigator.userAgent.toLowerCase().indexOf("android"),J=0,K={},L={},M=function(a){if("string"==typeof a&&(a=b.selector(a)),!a||a.nodeType)return[a];var c,d=[],e=a.length;for(c=0;c!==e;d.push(a[c++]));return d},N=function(a,b){var c,d={};if(b)for(c in a)d[c]=a[c]*b;else for(c in a)d[c]=a[c];return d},O=function(){for(var a=D.length;--a>-1;)D[a]()},P=function(a){D.push(a),1===D.length&&b.ticker.addEventListener("tick",O,this,!1,1)},Q=function(a){for(var c=D.length;--c>-1;)D[c]===a&&D.splice(c,1);b.to(R,0,{overwrite:"all",delay:15,onComplete:R,data:"_draggable"})},R=function(){D.length||b.ticker.removeEventListener("tick",O)},S=function(a,b){var c;for(c in b)void 0===a[c]&&(a[c]=b[c]);return a},T=function(){return null!=window.pageYOffset?window.pageYOffset:null!=s.scrollTop?s.scrollTop:t.scrollTop||s.body.scrollTop||0},U=function(){return null!=window.pageXOffset?window.pageXOffset:null!=s.scrollLeft?s.scrollLeft:t.scrollLeft||s.body.scrollLeft||0},V=function(a,b){Ia(a,"scroll",b),X(a.parentNode)||V(a.parentNode,b)},W=function(a,b){Ja(a,"scroll",b),X(a.parentNode)||W(a.parentNode,b)},X=function(a){return!(a&&a!==t&&a!==s&&a!==s.body&&a!==window&&a.nodeType&&a.parentNode)},Y=function(a,b){var c="x"===b?"Width":"Height",d="scroll"+c,e="client"+c,f=s.body;return Math.max(0,X(a)?Math.max(t[d],f[d])-(window["inner"+c]||t[e]||f[e]):a[d]-a[e])},Z=function(a){var b=X(a),c=Y(a,"x"),d=Y(a,"y");b?a=L:Z(a.parentNode),a._gsMaxScrollX=c,a._gsMaxScrollY=d,a._gsScrollX=a.scrollLeft||0,a._gsScrollY=a.scrollTop||0},$=function(a,b){return a=a||window.event,q.pageX=a.clientX+s.body.scrollLeft+t.scrollLeft,q.pageY=a.clientY+s.body.scrollTop+t.scrollTop,b&&(a.returnValue=!1),q},_=function(a){return a?("string"==typeof a&&(a=b.selector(a)),a.length&&a!==window&&a[0]&&a[0].style&&!a.nodeType&&(a=a[0]),a===window||a.nodeType&&a.style?a:null):a},aa=function(a,b){var c,e,f,g=a.style;if(void 0===g[b]){for(f=["O","Moz","ms","Ms","Webkit"],e=5,c=b.charAt(0).toUpperCase()+b.substr(1);--e>-1&&void 0===g[f[e]+c];);if(0>e)return"";d=3===e?"ms":f[e],b=d+c}return b},ba=function(a,b,c){var d=a.style;d&&(void 0===d[b]&&(b=aa(a,b)),null==c?d.removeProperty?d.removeProperty(b.replace(/([A-Z])/g,"-$1").toLowerCase()):d.removeAttribute(b):void 0!==d[b]&&(d[b]=c))},ca=s.defaultView?s.defaultView.getComputedStyle:x,da=/(?:Left|Right|Width)/i,ea=/(?:\d|\-|\+|=|#|\.)*/g,fa=function(a,b,c,d,e){if("px"===d||!d)return c;if("auto"===d||!c)return 0;var f,g=da.test(b),h=a,i=v.style,j=0>c;return j&&(c=-c),"%"===d&&-1!==b.indexOf("border")?f=c/100*(g?a.clientWidth:a.clientHeight):(i.cssText="border:0 solid red;position:"+ha(a,"position",!0)+";line-height:0;","%"!==d&&h.appendChild?i[g?"borderLeftWidth":"borderTopWidth"]=c+d:(h=a.parentNode||s.body,i[g?"width":"height"]=c+d),h.appendChild(v),f=parseFloat(v[g?"offsetWidth":"offsetHeight"]),h.removeChild(v),0!==f||e||(f=fa(a,b,c,d,!0))),j?-f:f},ga=function(a,b){if("absolute"!==ha(a,"position",!0))return 0;var c="left"===b?"Left":"Top",d=ha(a,"margin"+c,!0);return a["offset"+c]-(fa(a,b,parseFloat(d),(d+"").replace(ea,""))||0)},ha=function(a,b,c){var d,e=(a._gsTransform||{})[b];return e||0===e?e:(a.style[b]?e=a.style[b]:(d=ca(
|
||
|
f=vb({x:c.left+c.width/2,y:c.top+c.height/2}),g=vb({x:e.left+e.width/2,y:e.top+e.height/2}),j-=f.x-g.x,k-=f.y-g.y),Qa.isDragging||(Qa.isDragging=!0,ia(Qa,"dragstart","onDragStart"))},this.drag=qb,this.endDrag=function(a){sb(a||Qa.pointerEvent,!0)},this.timeSinceDrag=function(){return Qa.isDragging?0:(A()-Va)/1e3},this.timeSinceClick=function(){return(A()-bb)/1e3},this.hitTest=function(a,b){return Sa.hitTest(Qa.target,a,b)},this.getDirection=function(a,b){var c,d,e,g,h,i,j="velocity"===a&&f?a:"object"!=typeof a||za?"start":"element";return"element"===j&&(h=Wa(Qa.target),i=Wa(a)),c="start"===j?Qa.x-q:"velocity"===j?f.getVelocity(this.target,Ca):h.left+h.width/2-(i.left+i.width/2),za?0>c?"counter-clockwise":"clockwise":(b=b||2,d="start"===j?Qa.y-r:"velocity"===j?f.getVelocity(this.target,Da):h.top+h.height/2-(i.top+i.height/2),e=Math.abs(c/d),g=1/b>e?"":0>c?"left":"right",b>e&&(""!==g&&(g+="-"),g+=0>d?"up":"down"),g)},this.applyBounds=function(a){var b,c,e,f,h,i;if(a&&g.bounds!==a)return g.bounds=a,Qa.update(!0);if(eb(!0),fb(),u){if(b=Qa.x,c=Qa.y,b>x?b=x:D>b&&(b=D),c>G?c=G:O>c&&(c=O),(Qa.x!==b||Qa.y!==c)&&(e=!0,Qa.x=Qa.endX=b,za?Qa.endRotation=b:Qa.y=Qa.endY=c,ca=!0,db(!0),Qa.autoScroll&&!Qa.isDragging))for(Z(d.parentNode),f=d,L.scrollTop=null!=window.pageYOffset?window.pageYOffset:null!=t.scrollTop?t.scrollTop:s.body.scrollTop,L.scrollLeft=null!=window.pageXOffset?window.pageXOffset:null!=t.scrollLeft?t.scrollLeft:s.body.scrollLeft;f&&!i;)i=X(f.parentNode),h=i?L:f.parentNode,Fa&&h.scrollTop>h._gsMaxScrollY&&(h.scrollTop=h._gsMaxScrollY),Ea&&h.scrollLeft>h._gsMaxScrollX&&(h.scrollLeft=h._gsMaxScrollX),f=h;Qa.isThrowing&&(e||Qa.endX>x||Qa.endX<D||Qa.endY>G||Qa.endY<O)&&ib(g.throwProps,e)}return Qa},this.update=function(a,b,c){var e=Qa.x,f=Qa.y;return jb(!b),a?Qa.applyBounds():(ca&&c&&db(!0),eb(!0)),b&&(rb(Qa.pointerX,Qa.pointerY),ca&&db(!0)),Qa.isPressed&&!b&&(Ea&&Math.abs(e-Qa.x)>.01||Fa&&Math.abs(f-Qa.y)>.01&&!za)&&kb(),Qa.autoScroll&&(Z(d.parentNode),Xa=Qa.isDragging,db(!0)),Qa.autoScroll&&(W(d,tb),V(d,tb)),Qa},this.enable=function(a){var e,j,k;if("soft"!==a){for(j=Ta.length;--j>-1;)k=Ta[j],Ia(k,"mousedown",pb),Ia(k,"touchstart",pb),Ia(k,"click",ub,!0),za||ba(k,"cursor",g.cursor||"move"),ba(k,"touchCallout","none"),ba(k,"touchAction",Ea===Fa?"none":Ea?"pan-y":"pan-x"),sa(k)&&ba(k.ownerSVGElement||k,"touchAction",Ea===Fa?"none":Ea?"pan-y":"pan-x"),this.vars.allowContextMenu||Ia(k,"contextmenu",cb);Pa(Ta,!1)}return V(d,tb),h=!0,f&&"soft"!==a&&f.track(i||d,ya?"x,y":za?"rotation":"top,left"),i&&i.enable(),d._gsDragID=e="d"+F++,E[e]=this,i&&(i.element._gsDragID=e),b.set(d,{x:"+=0",overwrite:!1,data:"_draggable"}),qa={t:d,data:B?T:d._gsTransform,tween:{},setRatio:B?function(){b.set(d,R)}:c._internals.setTransformRatio||c._internals.set3DTransformRatio},kb(),Qa.update(!0),Qa},this.disable=function(a){var b,c,e=Qa.isDragging;if(!za)for(b=Ta.length;--b>-1;)ba(Ta[b],"cursor",null);if("soft"!==a){for(b=Ta.length;--b>-1;)c=Ta[b],ba(c,"touchCallout",null),ba(c,"touchAction",null),Ja(c,"mousedown",pb),Ja(c,"touchstart",pb),Ja(c,"click",ub),Ja(c,"contextmenu",cb);Pa(Ta,!0),la&&(Ja(la,"touchcancel",sb),Ja(la,"touchend",sb),Ja(la,"touchmove",qb)),Ja(s,"mouseup",sb),Ja(s,"mousemove",qb)}return W(d,tb),h=!1,f&&"soft"!==a&&f.untrack(i||d,ya?"x,y":za?"rotation":"top,left"),i&&i.disable(),Q(db),Qa.isDragging=Qa.isPressed=ka=!1,e&&ia(Qa,"dragend","onDragEnd"),Qa},this.enabled=function(a,b){return arguments.length?a?Qa.enable(b):Qa.disable(b):h},this.kill=function(){return Qa.isThrowing=!1,b.killTweensOf(i||d,!0,Ua),Qa.disable(),delete E[d._gsDragID],Qa},-1!==xa.indexOf("scroll")&&(i=this.scrollProxy=new Ra(d,S({onKill:function(){Qa.isPressed&&sb(null)}},g)),d.style.overflowY=Fa&&!Ga?"auto":"hidden",d.style.overflowX=Ea&&!Ga?"auto":"hidden",d=i.content),g.force3D!==!1&&b.set(d,{force3D:!0}),za?Ua.rotation=1:(Ea&&(Ua[Ca]=1),Fa&&(Ua[Da]=1)),za?(R=o,T=R.css,R.overwrite=!1):ya&&(R=Ea&&Fa?l:Ea?m:n,T=R.css,R.overwrite=!1),this.enable()},Ta=Sa.prototype=new a;Ta.constructor=Sa,Ta.pointerX=Ta.pointerY=Ta.startX=Ta.startY=Ta.deltaX=Ta.deltaY=0,Ta.isDrag
|