1
0
mirror of https://github.com/StarGazer114/stargazer114.github.io.git synced 2025-01-09 23:08:16 +08:00
stargazer114.github.io/pluginsSrc/butterfly-extsrc/dist/fireworks.min.js

1 line
19 KiB
JavaScript
Raw Permalink Normal View History

2025-01-05 20:41:38 +08:00
(()=>{const n=document.querySelector(".fireworks");if(!n)return;const e="false"===n.getAttribute("mobile"),t=/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(navigator.userAgent);if(e&&t)return;(()=>{var n,e;n=this,e=function(){"use strict";var n={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0},e={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},t=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],r={CSS:{},springs:{}};function a(n,e,t){return Math.min(Math.max(n,e),t)}function o(n,e){return-1<n.indexOf(e)}function i(n,e){return n.apply(null,e)}var u={arr:function(n){return Array.isArray(n)},obj:function(n){return o(Object.prototype.toString.call(n),"Object")},pth:function(n){return u.obj(n)&&n.hasOwnProperty("totalLength")},svg:function(n){return n instanceof SVGElement},inp:function(n){return n instanceof HTMLInputElement},dom:function(n){return n.nodeType||u.svg(n)},str:function(n){return"string"==typeof n},fnc:function(n){return"function"==typeof n},und:function(n){return void 0===n},nil:function(n){return u.und(n)||null===n},hex:function(n){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(n)},rgb:function(n){return/^rgb/.test(n)},hsl:function(n){return/^hsl/.test(n)},col:function(n){return u.hex(n)||u.rgb(n)||u.hsl(n)},key:function(t){return!n.hasOwnProperty(t)&&!e.hasOwnProperty(t)&&"targets"!==t&&"keyframes"!==t}};function s(n){return(n=/\(([^)]+)\)/.exec(n))?n[1].split(",").map((function(n){return parseFloat(n)})):[]}function c(n,e){var t=s(n),o=a(u.und(t[0])?1:t[0],.1,100),i=a(u.und(t[1])?100:t[1],.1,100),c=a(u.und(t[2])?10:t[2],.1,100),l=(t=a(u.und(t[3])?0:t[3],.1,100),Math.sqrt(i/o)),d=c/(2*Math.sqrt(i*o)),f=d<1?l*Math.sqrt(1-d*d):0,h=d<1?(d*l-t)/f:-t+l;function p(n){var t=e?e*n/1e3:n;return t=d<1?Math.exp(-t*d*l)*(+Math.cos(f*t)+h*Math.sin(f*t)):(1+h*t)*Math.exp(-t*l),0===n||1===n?n:1-t}return e?p:function(){var e=r.springs[n];if(e)return e;for(var t=0,a=0;;)if(1===p(t+=1/6)){if(16<=++a)break}else a=0;return e=t*(1/6)*1e3,r.springs[n]=e}}function l(n){return void 0===n&&(n=10),function(e){return Math.ceil(a(e,1e-6,1)*n)*(1/n)}}var d=function(n,e,t,r){if(0<=n&&n<=1&&0<=t&&t<=1){var a=new Float32Array(11);if(n!==e||t!==r)for(var o=0;o<11;++o)a[o]=h(.1*o,n,t);return function(o){return n===e&&t===r||0===o||1===o?o:h(function(e){for(var r=0,o=1;10!==o&&a[o]<=e;++o)r+=.1;var i=r+(e-a[--o])/(a[o+1]-a[o])*.1,u=p(i,n,t);if(.001<=u){for(var s=e,c=i,l=n,d=t,f=0;f<4;++f){var g=p(c,l,d);if(0===g)return c;c-=(h(c,l,d)-s)/g}return c}if(0===u)return i;for(var m,v,y=e,b=r,x=r+.1,w=n,M=t,P=0;0<(m=h(v=b+(x-b)/2,w,M)-y)?x=v:b=v,1e-7<Math.abs(m)&&++P<10;);return v}(o),e,r)}}};function f(n,e){return 1-3*e+3*n}function h(n,e,t){return((f(e,t)*n+(3*t-6*e))*n+3*e)*n}function p(n,e,t){return 3*f(e,t)*n*n+2*(3*t-6*e)*n+3*e}g={linear:function(){return function(n){return n}}},m={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Expo:function(){return function(n){return n?Math.pow(2,10*n-10):0}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var e,t=4;n<((e=Math.pow(2,--t))-1)/11;);return 1/Math.pow(4,3-t)-7.5625*Math.pow((3*e-2)/22-n,2)}},Elastic:function(n,e){void 0===e&&(e=.5);var t=a(n=void 0===n?1:n,1,10),r=a(e,.1,2);return function(n){return 0===n||1===n?n:-t*Math.pow(2,10*(n-1))*Math.sin((n-1-r/(2*Math.PI)*Math.asin(1/t))*(2*Math.PI)/r)}}},["Quad","Cubic","Quart","Quint"].forEach((function(n,e){m[n]=function(){return function(n){return Math.pow(n,e+2)}}})),Object.keys(m).forEach((function(n){var e=m[n];g["easeIn"+n]=e,g["easeOut"+n]=function(n,t){return function(r){return 1-e(n,t)(1-r)}},g["easeInOut"+n]=function(n,t){return function(r){return r<.5?e(n,t)(2*r)/2:1-e(n,t)(-2*r+2)/2}},g["easeOutIn"+n]=function(n,t){return function(r){retu