3 lines
18 KiB
JavaScript
3 lines
18 KiB
JavaScript
|
|
const t=(t,e)=>{const i=e.x-t.x,o=e.y-t.y;return Math.sqrt(i*i+o*o)},e=t=>t*(Math.PI/180),i=t=>t*(180/Math.PI),o=new Map,n=t=>{o.has(t)&&clearTimeout(o.get(t)),o.set(t,setTimeout(t,100))},r=(t,e,i)=>{const o=e.split(/[ ,]+/g);let n;for(let e=0;e<o.length;e+=1)n=o[e],t.addEventListener?t.addEventListener(n,i,!1):t.attachEvent&&t.attachEvent(n,i)},s=(t,e,i)=>{const o=e.split(/[ ,]+/g);let n;for(let e=0;e<o.length;e+=1)n=o[e],t.removeEventListener?t.removeEventListener(n,i):t.detachEvent&&t.detachEvent(n,i)},d=t=>(t.preventDefault(),t.type.match(/^touch/)?t.changedTouches:t),a=()=>({x:void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,y:void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop}),p=(t,e)=>{e.top||e.right||e.bottom||e.left?(t.style.top=e.top,t.style.right=e.right,t.style.bottom=e.bottom,t.style.left=e.left):(t.style.left=e.x+"px",t.style.top=e.y+"px")},l=(t,e,i)=>{const o=c(t);for(let t in o)if(o.hasOwnProperty(t))if("string"==typeof e)o[t]=e+" "+i;else{let n="";for(let t=0,o=e.length;t<o;t+=1)n+=e[t]+" "+i+", ";o[t]=n.slice(0,-2)}return o},c=t=>{const e={};e[t]="";return["webkit","Moz","o"].forEach(function(i){e[i+t.charAt(0).toUpperCase()+t.slice(1)]=""}),e},h=(t,e)=>{for(let i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t},u=(t,e)=>{if(t.length)for(let i=0,o=t.length;i<o;i+=1)e(t[i]);else e(t)};var f,y=!!("ontouchstart"in window),m=!!window.PointerEvent,v=!!window.MSPointerEvent,g={start:"mousedown",move:"mousemove",end:"mouseup"},x={};function b(){}function O(t,e){return this.identifier=e.identifier,this.position=e.position,this.frontPosition=e.frontPosition,this.collection=t,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(e),"dynamic"===this.options.mode&&(this.options.restOpacity=0),this.id=O.id,O.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}function w(t,e){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=t,i.id=w.id,w.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(e),"static"!==i.options.mode&&"semi"!==i.options.mode||(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);const o=getComputedStyle(i.options.zone.parentElement);return o&&"flex"===o.display&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}function _(t){var e=this;e.ids={},e.index=0,e.collections=[],e.scroll=a(),e.config(t),e.prepareCollections();var i=function(){var t;e.collections.forEach(function(i){i.forEach(function(i){t=i.el.getBoundingClientRect(),i.position={x:e.scroll.x+t.left,y:e.scroll.y+t.top}})})};r(window,"resize",function(){n(i)});var o=function(){e.scroll=a()};return r(window,"scroll",function(){n(o)}),e.collections}m?f={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:v?f={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:y?(f={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},x=g):f=g,b.prototype.on=function(t,e){var i,o=this,n=t.split(/[ ,]+/g);o._handlers_=o._handlers_||{};for(var r=0;r<n.length;r+=1)i=n[r],o._handlers_[i]=o._handlers_[i]||[],
|
||
|
|
//# sourceMappingURL=index.js.map
|