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

3 lines
7.6 KiB
JavaScript
Raw Normal View History

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