kute.js/demo/src/kute-base.min.js

3 lines
8.4 KiB
JavaScript
Raw Normal View History

// KUTE.js Base v2.2.0alpha2 | thednp © 2021 | MIT-License
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).KUTE=e()}(this,(function(){"use strict";var t={},e=[],n="undefined"!=typeof global?global:"undefined"!=typeof window?window.self:{},i={},o={},r="undefined"==typeof self&&"undefined"!=typeof process&&process.hrtime?function(){var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:"undefined"!=typeof self&&void 0!==self.performance&&void 0!==self.performance.now?self.performance.now.bind(self.performance):"undefined"!=typeof Date&&Date.now?Date.now:function(){return(new Date).getTime()},a={};a.now=r;var s=0,c=function(t){for(var n=0;n<e.length;)e[n].update(t)?n+=1:e.splice(n,1);s=requestAnimationFrame(c)};function u(){setTimeout((function(){!e.length&&s&&(cancelAnimationFrame(s),s=null,Object.keys(o).forEach((function(e){"function"==typeof o[e]?t[e]&&delete t[e]:Object.keys(o[e]).forEach((function(e){t[e]&&delete t[e]}))})),Object.keys(i).forEach((function(e){t[e]&&delete t[e]})))}),64)}var f={Tick:s,Ticker:c,Tweens:e,Time:a};Object.keys(f).forEach((function(e){t[e]||(t[e]="Time"===e?a.now:f[e])})),n._KUTE=t;var l={duration:700,delay:0,easing:"linear",repeat:0,repeatDelay:0,yoyo:!1,resetStart:!1,offset:0},h={},p={},d={defaultOptions:l,linkProperty:h,onStart:o,onComplete:p},y={},v={tween:null,processEasing:null},m={linear:function(t){return t},easingQuadraticIn:function(t){return t*t},easingQuadraticOut:function(t){return t*(2-t)},easingQuadraticInOut:function(t){return t<.5?2*t*t:(4-2*t)*t-1},easingCubicIn:function(t){return t*t*t},easingCubicOut:function(t){var e=t-1;return e*e*e+1},easingCubicInOut:function(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},easingCircularIn:function(t){return-(Math.sqrt(1-t*t)-1)},easingCircularOut:function(t){var e=t-1;return Math.sqrt(1-e*e)},easingCircularInOut:function(t){var e=2*t;return e<1?-.5*(Math.sqrt(1-e*e)-1):(e-=2,.5*(Math.sqrt(1-e*e)+1))},easingBackIn:function(t){var e=1.70158;return t*t*((e+1)*t-e)},easingBackOut:function(t){var e=1.70158,n=t-1;return n*n*((e+1)*n+e)+1},easingBackInOut:function(t){var e=2.5949095,n=2*t;return n<1?n*n*((e+1)*n-e)*.5:.5*((n-=2)*n*((e+1)*n+e)+2)}};v.processEasing=function(t){return"function"==typeof t?t:"function"==typeof m[t]?m[t]:m.linear};var g=function(t){return e.push(t)},E=function(t){var n=e.indexOf(t);-1!==n&&e.splice(n,1)},b={};function _(){var e=this;Object.keys(h).forEach((function(n){var i=h[n],o=b[n];Object.keys(i).forEach((function(n){"function"==typeof i[n]&&Object.keys(e.valuesEnd).some((function(t){return o&&o.includes(t)||"attr"===t&&Object.keys(e.valuesEnd[t]).some((function(t){return o&&o.includes(t)}))}))?t[n]||(t[n]=i[n]):Object.keys(e.valuesEnd).forEach((function(o){var r=e.valuesEnd[o];r instanceof Object&&Object.keys(r).forEach((function(e){"function"==typeof i[e]?t[e]||(t[e]=i[e]):Object.keys(i[n]).forEach((function(n){i[e]&&"function"==typeof i[e][n]&&(t[n]||(t[n]=i[e][n]))}))}))}))}))}))}var O={add:g,remove:E,getAll:function(){return e},removeAll:function(){e.length=0},stop:u,linkInterpolation:_};function k(t,e){try{var n,i;return e?(i=t instanceof Array&&t.every((function(t){return t instanceof Element})),n=t instanceof HTMLCollection||t instanceof NodeList||i?t:document.querySelectorAll(t)):n=t instanceof Element||t===window?t:document.querySelector(t),n}catch(e){throw TypeError("KUTE.js - Element(s) not found: "+t+".")}}var j=function(t){var e=t.component,n={onStart:o,onComplete:p},r=t.category,a=t.property;return this._=0,b[e]=t.properties||t.subProperties||t.property,t.defaultOptions&&Object.assign(l,t.defaultOptions),t.functions&&Object.keys(n).forEach((function(i){i in t.functions&&("function"==typeof t.functions[i]?(n[i][e]||(n[i][e]={}),n[i][e][r||a]||(n[i][e][r||a]=t.functions[i])):Object.keys(t.functions[i]).forEach((function(o){n[i][e]||(n[i][e]={}),n[i][e][o]||(n[i][e][o]=t.functions[i][o])})))})),t.Interpolate&&(Object.keys(t.Interpolate).forEach((function(e){var n=t.Interpolate[e];"function"!=typeof n||i[e]?Object.keys(n).