pixi-tweener
Version:
Simple tweener for pixi.js, with promises
2 lines • 5.44 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.pixiTweener=e():t.pixiTweener=e()}(self,(function(){return(()=>{"use strict";var t={679:(t,e)=>{e.__esModule=!0,e.Easing=void 0;var n=function(){function t(){}return t.linear=function(t){return t},t.easeInQuad=function(t){return Math.pow(t,2)},t.easeOutQuad=function(t){return-(Math.pow(t-1,2)-1)},t.easeInOutQuad=function(t){return(t/=.5)<1?.5*Math.pow(t,2):-.5*((t-=2)*t-2)},t.easeInCubic=function(t){return Math.pow(t,3)},t.easeOutCubic=function(t){return Math.pow(t-1,3)+1},t.easeInOutCubic=function(t){return(t/=.5)<1?.5*Math.pow(t,3):.5*(Math.pow(t-2,3)+2)},t.easeInQuart=function(t){return Math.pow(t,4)},t.easeOutQuart=function(t){return-(Math.pow(t-1,4)-1)},t.easeInOutQuart=function(t){return(t/=.5)<1?.5*Math.pow(t,4):-.5*((t-=2)*Math.pow(t,3)-2)},t.easeInQuint=function(t){return Math.pow(t,5)},t.easeOutQuint=function(t){return Math.pow(t-1,5)+1},t.easeInOutQuint=function(t){return(t/=.5)<1?.5*Math.pow(t,5):.5*(Math.pow(t-2,5)+2)},t.easeInSine=function(t){return 1-Math.cos(t*(Math.PI/2))},t.easeOutSine=function(t){return Math.sin(t*(Math.PI/2))},t.easeInOutSine=function(t){return-.5*(Math.cos(Math.PI*t)-1)},t.easeInExpo=function(t){return 0===t?0:Math.pow(2,10*(t-1))},t.easeOutExpo=function(t){return 1===t?1:1-Math.pow(2,-10*t)},t.easeInOutExpo=function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*--t))},t.easeInCirc=function(t){return-(Math.sqrt(1-t*t)-1)},t.easeOutCirc=function(t){return Math.sqrt(1-Math.pow(t-1,2))},t.easeInOutCirc=function(t){return(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},t.easeOutBounce=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},t.easeInBack=function(t){var e=1.70158;return t*t*((e+1)*t-e)},t.easeOutBack=function(t){var e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},t.easeInOutBack=function(t){var e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},t.elastic=function(t){return-1*Math.pow(4,-8*t)*Math.sin((6*t-1)*(2*Math.PI)/2)+1},t.swingFromTo=function(t){var e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},t.swingFrom=function(t){var e=1.70158;return t*t*((e+1)*t-e)},t.swingTo=function(t){var e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},t.bounce=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},t.bouncePast=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?2-(7.5625*(t-=1.5/2.75)*t+.75):t<2.5/2.75?2-(7.5625*(t-=2.25/2.75)*t+.9375):2-(7.5625*(t-=2.625/2.75)*t+.984375)},t.easeFromTo=function(t){return(t/=.5)<1?.5*Math.pow(t,4):-.5*((t-=2)*Math.pow(t,3)-2)},t.easeFrom=function(t){return Math.pow(t,4)},t.easeTo=function(t){return Math.pow(t,.25)},t}();e.Easing=n},919:function(t,e,n){var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};e.__esModule=!0,o(n(679),e),o(n(60),e)},60:function(t,e,n){var r=this&&this.__spreadArrays||function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),o=0;for(e=0;e<n;e++)for(var u=arguments[e],a=0,i=u.length;a<i;a++,o++)r[o]=u[a];return r};e.__esModule=!0,e.Tweener=void 0;var o=n(679),u=function(){function t(){}return t.init=function(e){t.ticker||(t.ticker=e,t.ticker.add(t.update))},t.tweening=function(){return t.tweens.length>0},t.dispose=function(){t.ticker&&(t.ticker.remove(t.update),t.ticker=void 0,t.tweens=[])},t.add=function(e,n){var u=e.target,a=Object.assign.apply(Object,r([{}],Object.keys(n).map((function(t){var e;return(e={})[t]=u[t],e})))),i=Object.assign.apply(Object,r([{}],Object.keys(n).map((function(t){var e;return(e={})[t]=n[t]-a[t],e})))),c=e.useTickForDuration?e.duration:1e3*e.duration;return new Promise((function(r){var s={duration:c,useTickForDuration:!!e.useTickForDuration,ease:e.ease||o.Easing.linear,target:e.target,delay:e.delay?1e3*e.delay:0,currentTime:0,props:n,propDeltas:i,startingProps:a,onComplete:r,onUpdate:e.onUpdate||void 0,context:e.context||u};t.tweens.push(s)}))},t.killTweensOf=function(e,n){var r=[];t.tweens.forEach((function(t){t.context===e||t.target===e?!n&&t.onComplete():r.push(t)})),t.tweens=r},t.advance=function(e){for(var n=!1,r=0,o=t.tweens;r<o.length;r++){var u=o[r],a=u.useTickForDuration?1:e;if(u.delay>0){if(u.delay-=a,!(u.delay<=0))continue;a=-u.delay}u.currentTime+=a;for(var i=Math.min(1,u.currentTime/u.duration),c=u.ease(i),s=0,f=Object.keys(u.props);s<f.length;s++){var p=f[s];u.target[p]=u.startingProps[p]+c*u.propDeltas[p]}u.onUpdate&&u.onUpdate(i),u.currentTime>=u.duration&&(u.onComplete(),n=!0)}n&&(t.tweens=t.tweens.filter((function(t){return t.currentTime<t.duration})))},t.tweens=[],t.update=function(){return t.advance(t.ticker.elapsedMS)},t}();e.Tweener=u}},e={};return function n(r){if(e[r])return e[r].exports;var o=e[r]={exports:{}};return t[r].call(o.exports,o,o.exports,n),o.exports}(919)})()}));
//# sourceMappingURL=pixi-tweener.js.map