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

3 lines
7.2 KiB
JavaScript
Raw Normal View History

// KUTE.js Base v2.0.16 | thednp © 2020 | 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:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},i={},r={},o={};o.now=self.performance.now.bind(self.performance);var a=0,s=function(t){for(var e=0;e<n.length;)n[e].update(t)?e++:n.splice(e,1);a=requestAnimationFrame(s)};function u(){setTimeout((function(){if(!n.length&&a){for(var e in cancelAnimationFrame(a),a=null,r)if("function"==typeof r[e])t[e]&&delete t[e];else for(var o in r[e])t[o]&&delete t[o];for(var s in i)t[s]&&delete t[s]}}),64)}var f={Tick:a,Ticker:s,Tweens:n,Time:o};for(var c in f)t[c]||(t[c]="Time"===c?o.now:f[c]);e._KUTE=t;var l={duration:700,delay:0,easing:"linear"},p={},h={},d={defaultOptions:l,linkProperty:p,onStart:r,onComplete:h},v={},y={},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){return--t*t*t+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){return Math.sqrt(1-(t-=1)*t)},easingCircularInOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easingBackIn:function(t){var n=1.70158;return t*t*((n+1)*t-n)},easingBackOut:function(t){var n=1.70158;return--t*t*((n+1)*t+n)+1},easingBackInOut:function(t){var n=2.5949095;return(t*=2)<1?t*t*((n+1)*t-n)*.5:.5*((t-=2)*t*((n+1)*t+n)+2)}};function g(t){return n.push(t)}function _(t){var e=n.indexOf(t);-1!==e&&n.splice(e,1)}y.processEasing=function(t){return"function"==typeof t?t:"function"==typeof m[t]?m[t]:m.linear};var S={};function w(){var n=this,e=function(e){var i=p[e],r=S[e];for(var o in i)if("function"==typeof i[o]&&Object.keys(n.valuesEnd).some((function(t){return r&&r.includes(t)||"attr"===t&&Object.keys(n.valuesEnd[t]).some((function(t){return r&&r.includes(t)}))})))!t[o]&&(t[o]=i[o]);else for(var a in n.valuesEnd)for(var s in n.valuesEnd[a])if("function"==typeof i[s])!t[s]&&(t[s]=i[s]);else for(var u in i[o])i[s]&&"function"==typeof i[s][u]&&!t[u]&&(t[u]=i[s][u])};for(var i in p)e(i)}var T={add:g,remove:_,getAll:function(){return n},removeAll:function(){n.length=0},stop:u,linkInterpolation:w};function C(t,n){try{return n?t instanceof HTMLCollection||t instanceof NodeList||t instanceof Array&&t.every((function(t){return t instanceof Element}))?t:document.querySelectorAll(t):t instanceof Element||t===window?t:document.querySelector(t)}catch(n){console.error("KUTE.js - Element(s) not found: "+t+".")}}var M=function(t){return this.setComponent(t)};function b(){for(var t in r)if("function"==typeof r[t])r[t].call(this,t);else for(var n in r[t])r[t][n].call(this,n);w.call(this)}M.prototype.setComponent=function(t){var n=t.component,e={onStart:r,onComplete:h},o=t.category,a=t.property;if(S[n]=t.properties||t.subProperties||t.property,t.defaultOptions)for(var s in t.defaultOptions)l[s]=t.defaultOptions[s];if(t.functions)for(var u in e)if(u in t.functions)if("function"==typeof t.functions[u])!e[u][n]&&(e[u][n]={}),!e[u][n][o||a]&&(e[u][n][o||a]=t.functions[u]);else for(var f in t.functions[u])!e[u][n]&&(e[u][n]={}),!e[u][n][f]&&(e[u][n][f]=t.functions[u][f]);if(t.Interpolate){for(var c in t.Interpolate){var d=t.Interpolate[c];if("function"!=typeof d||i[c])for(var y in d)"function"!=typeof d[y]||i[c]||(i[c]=d[y]);else i[c]=d}p[n]=t.Interpolate}if(t.Util)for(var m in t.Util)!v[m]&&(v[m]=t.Util[m]);return{name:n}};var E=function(n,e,i,o){for(var a in this.element=n,this.playing=!1,this._startTime=null,this._startFired=!1,this.valuesEnd=i,this.valuesStart=e,o=o||{},this._resetStart=o.resetStart||0,this._easing="function"==typeof o.easing?o.easing:y.processEasing(o.easing),this._duration=o.duration||l.duration,this._delay=o.