lwa 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lwa.cjs +2 -0
- package/dist/{lwa.es.js → lwa.full.es.js} +1 -1
- package/dist/{lwa.umd.js → lwa.full.umd.js} +1 -1
- package/dist/{lwa.js → lwa.mjs} +1 -1
- package/dist/lwa.slim.d.ts +223 -0
- package/dist/lwa.slim.js +749 -0
- package/package.json +27 -7
package/dist/lwa.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* lwa 0.2.3 | MIT license | https://github.com/sutras/lwa */
|
|
2
|
+
"use strict";var e=Object.defineProperty,t=Math.pow,n=(t,n,r)=>((t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r)(t,"symbol"!=typeof n?n+"":n,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const{request:r,cancel:o}=function(){if("function"==typeof requestAnimationFrame)return{request:requestAnimationFrame,cancel:cancelAnimationFrame};const e=[];let t,n=1,r=0;function o(){t=void 0;const n=e.slice();r+=e.length,e.length=0,n.forEach((e=>{0!==e&&e(Date.now())}))}return{request:r=>(e.push(r),t||(t=setTimeout(o,1e3/60)),n++),cancel(t){e[t-r]=0}}}(),a=new Set;let i=0,f=!0;function s(){0===a.size?f||(f=!0,o(i)):(new Set(a).forEach((e=>e())),i=r(s))}const c={add:function(e){a.add(e),f&&(f=!1,i=r(s))},remove:function(e){a.delete(e)}},u={linear:()=>e=>e},l={Sine:()=>e=>1-Math.cos(e*Math.PI/2),Expo:()=>e=>e?Math.pow(1024,e-1):0,Circ:()=>e=>1-Math.sqrt(1-e*e),Elastic:()=>e=>0===e||1===e?e:-Math.pow(2,10*e-10)*Math.sin(2*(10*e-10.75)*Math.PI/3),Back:()=>e=>{const t=1.70158;return e*e*((t+1)*e-t)},Bounce:()=>e=>{const t=7.5625,n=2.75;return 1-((e=1-e)<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375)}};["Quad","Cubic","Quart","Quint"].forEach(((e,t)=>{l[e]=()=>e=>Math.pow(e,t+2)})),Object.keys(l).forEach((e=>{const t=l[e];u["easeIn"+e]=t,u["easeOut"+e]=(e,n)=>r=>1-t(e,n)(1-r),u["easeInOut"+e]=(e,n)=>r=>r<.5?t(e,n)(2*r)/2:1-t(e,n)(2-2*r)/2}));const d=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/,g=new RegExp("^([+\\-*/%]=|)("+d.source+")("+/%|px|rpx|em|rem|vw|vh|deg|rad|turn|ex|ch|vmin|vmax|pc|pt|in|cm|mm/.source+"|)$","i"),p=new RegExp(d.source,"g"),m=new RegExp("^([<>]|)([+-]=|)("+d.source+"|)(%|)$");function h(e){return"number"==typeof e}function b(e){return"string"==typeof e}function y(e){return null!==e&&"object"==typeof e}function w(e){return"function"==typeof e}function x(e){return Array.isArray(e)}function k(e){return Array.isArray(e)?e:[e]}function v(e){return w(e)?e:()=>(u[e]||u.linear)(0,0)}const M=Symbol();class E{}class S extends E{constructor(e,t){super(),n(this,"from"),n(this,"to"),this.from=e,this.to=t}}class q extends E{constructor(e,t,r){super(),n(this,"el"),n(this,"prop"),n(this,"totalLength"),this.el=e,this.prop=t,this.totalLength=r}}const A=[];function O(e){const n=[];return x(e)||(e=[e]),e.flat().forEach((e=>{e&&(b(e)?n.push(...Array.from(document.querySelectorAll(e))):!function(e){let n;return y(e)&&Number.isInteger(n=e.length)&&n<t(2,32)}(e)?(y(e)||w(e))&&n.push(e):n.push(...Array.from(e)))})),Array.from(new Set(n))}function P(e,t){return w(e)?e(t.target,t.index,t.total):e}function T(e,t){const{duration:n,delay:r,begin:o,easing:a,between:i}=t;return i.map((t=>function(t){const{from:i,to:f,round:s}=t;let c=e<=o+r?i:e>=o+r+n?f:i+a((e-o-r)/n)*(f-i);return s&&(c=Math.round(c*s)/s),c}(t)))}function C(e,t){return x(e=P(e,t))?e.map((e=>C(e,t)[0])):((h(e)||b(e)||e instanceof E)&&(e={value:e}),[e])}function D(e,t,n,r,o,a,i){const f=t.length;let s,c=o||0;i=(null!=i?i:r.duration)/f;const u=t.map(((t,o)=>s=function(t,o,s){var u,l,d,p,m,h,y;const w=P(null!=(u=t.duration)?u:i,e),x=P(null!=(l=t.delay)?l:0===o?r.delay:0,e),k=P(null!=(d=t.endDelay)?d:o===f-1?r.endDelay:0,e),E=P(v(null!=(p=t.easing)?p:r.easing),e),q=P(null!=(m=t.round)?m:r.round,e),O=x+w+k,T=c,C=T+O;if(c+=O,!s){let e;s=(e=a[n])?e[e.length-1]:void 0}const D=t.value;let $,j;const L=D instanceof S;L?(j=P(D.from,e),$=P(D.to,e)):$=D,!L&&s&&(j=s.to);let I=!1;void 0===j&&(j=e.target[n],I=!0);let F="",N="";if(b($)){const e=g.exec($);e&&(F=e[1],$=parseFloat(e[2])||0,N=e[3])}const z={animatedTarget:e,prop:n,duration:w,delay:x,endDelay:k,begin:T,end:C,easing:E,data:{},from:j,to:$,withoutFrom:I,round:q,unit:N,operator:F,between:[]};for(let e=0,n=A.length;e<n&&(null==(y=(h=A[e]).init)?void 0:y.call(h,z,M))!==M;e++);return z}(t,o,s))).sort(((e,t)=>e.begin-t.begin));return{endTime:c,tweens:u}}function $(e,t,n){const r={},o=P(n.duration,e)/t.length;let a=0;return t.forEach((t=>{const i=function(e,t,n,r,o,a){let i={};for(let f in t){const s=t[f];null!=s&&(i[f]=D(e,C(s,e),f,n,r,o,a))}return i}(e,t,n,a,r,o);for(let e in i)a=Math.max(a,i[e].endTime),r[e]=(r[e]||[]).concat(i[e].tweens)})),r}function j(e,t,n){return e.map((e=>{const r=$(e,t,n);return Object.keys(r).map((e=>{return{seek:function(e){var n,r;let o;for(let a,i=0;a=t[i++];){if(a.begin<=e&&a.end>=e){o=a;break}e>a.end&&(!t[i+1]||t[i+1].begin>e)&&(o=a)}if(o){let t,a=T(e,o);for(let e=A.length-1;e>=0;e--){if(t=null==(r=(n=A[e]).update)?void 0:r.call(n,o,a,M),t===M)return;void 0!==t&&(a=t)}}},getDuration:function(){return Math.max(...t.map((e=>e.end)))},tweens:t=r[e]};var t}))})).flat()}const L={duration:500,delay:0,endDelay:0,easing:"easeInOutQuad",round:0};function I(e){k(e).forEach((e=>{A.includes(e)||(A.push(e),A.sort(((e,t)=>t.order-e.order)))}))}const F="alternate-reverse",N="reverse",z="alternate";function R(e){return e===N||e===F}function X(e){return e===z||e===F}const Y={externalTicker:!1,autoplay:!0,direction:"normal",loop:1},B=["begin","loopBegin","complete","loopComplete","pause","play","update"];function G(e){const t=Object.assign({},Y,e),{externalTicker:n,autoplay:r,direction:o,loop:a}=t;let i=!1,f=!0,s=0,u=0,l=a,d=R(o),g=0,p=[];const w=function(){const e={};function t(t,n){let r=e[t];r||(r=e[t]=new Set),r.add(n)}function n(t,n){if(n){const r=e[t];r&&(r.delete(n),0===r.size&&delete e[t])}else delete e[t]}return{on:t,off:n,once:function(e,r){t(e,(function t(...o){r(...o),n(e,t)}))},emit:function(t,...n){const r=e[t];r&&r.forEach((e=>{e(...n)}))}}}();function k(){return 0===l&&u===g}function v(e){let t=!1;e>=g?(e=g,t=!0):e<0&&(e=0),u=e;const n=d?g-u:u;p.forEach((({target:e,begin:t})=>{e.seek(n-t)})),w.emit("update",n,0===g?0:u/g),t&&(w.emit("loopComplete"),--l<0&&(l=0),0===l?(q(),w.emit("complete")):f||(X(o)&&(d=!d),E()))}function M(){if(!f){let e=Date.now();v(e-s+u),s=e}}function E(){i?u=0:(i=!0,w.emit("begin")),w.emit("loopBegin"),S()}function S(){i?f&&(f=!1,k()?(X(o)&&(d=!d),A()):(s=Date.now(),n||c.add(M),w.emit("play"))):E()}function q(){f||(f=!0,n||c.remove(M),w.emit("pause"))}function A(){q(),u=0,i=!1,l=a,d=R(o),S()}function P(e,t,n,r){if(function(e){return y(e)&&"getDuration"in e&&"seek"in e}(e)){let n=g;if(h(r=null!=t?t:">"))n=r;else{const{begin:e,end:t}=p[p.length-1]||{begin:0,end:0},o=t-e,[,a,i,f,s]=m.exec(r)||[,">","","",""];n="<"===a?e:">"===a?t:n;let c=+f;"%"===s&&(c=(a?o:g)/100*+f),n+="-="===i?-c:c}n=Math.max(0,n);const o=n+e.getDuration();p.push({target:e,position:r,begin:n,end:o}),g=Math.max(g,o)}else{(h(n)||b(n))&&(r=n,n=void 0);const o=function(e,t,n){const r=Object.assign({},L,n);return j((o=O(e)).map(((e,t)=>({target:e,index:t,total:o.length}))),x(t)?t:[t],r);var o}(e,t,n);o.forEach(((e,t)=>{P(e,0===t?r:"<")}))}return T}B.forEach((e=>{t[e]&&w.on(e,t[e])})),r&&0!==a&&E();const T={play:S,pause:q,finish:function(){k()||v(g)},restart:A,seek:v,progress:function(e){var t,n,r;v((r=1,((t=e)<(n=0)?n:t>r?r:t)*g))},tick:()=>{n&&M()},getPosition:()=>u,getDuration:()=>g,getProgress:()=>0===g?0:u/g,isReverse:()=>d,add:P,remove:function(e){const t=p.findIndex((t=>t.target===e));-1!==t&&(p.splice(t,1),function(){const e=[...p];p=[],g=0,e.forEach((e=>{P(e.target,e.position)}))}())},clear:function(){q(),g=0,p=[]},events:p,on:w.on,off:w.off,once:w.once};return T}const Q={start:0,from:0,direction:"normal",easing:"linear",grid:null,axis:null};const Z={order:100,update(e,t,n){const{animatedTarget:r,prop:o,unit:a}=e;let i=x(t)?t[0]:t;return a&&(i+=a),r.target[o]=i,n}},U={order:0,init(e,t){if(0===e.between.length){const n=k(e.to),r=k(e.from);return e.between=n.map(((t,n)=>({from:+r[n]||0,to:+t||0,round:e.round}))),t}}},V={},_=["","webkit","Moz"],H=document.documentElement,W=["translateX","translateY","translateZ","scale","scaleX","scaleY","scaleZ","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY","perspective"],J=te(W),K=te(["columnCount","fillOpacity","fontSizeAdjust","fontWeight","lineHeight","opacity","orphans","widows","zIndex","zoom","scale","scaleX","scaleY","scaleZ","order","flexGrow","flexShrink","scrollLeft","scrollTop","strokeDashoffset","strokeDasharray"]),ee=te(["value"]);function te(e){const t={};for(let n=0,r=e.length;n<r;n++)t[e[n]]=!0;return t}function ne(e){return e.replace(/[-]([^-])/g,((e,t)=>t.toUpperCase())).replace(/^./,(e=>e.toLowerCase()))}function re(e,t){if(V[e])return V[e];t=t||H.style;for(let n=0,r=_.length;n<r;n++){const t=_[n];let r=t?t+String(e).replace(/[-]([^-])/g,((e,t)=>t.toUpperCase())).replace(/^./,(e=>e.toUpperCase())):ne(String(e));if(r in H.style)return V[e]=r}return""}function oe(e,t){return t+(Number.isNaN(+t)||K[e]?"":"px")}function ae(e,t){return window.getComputedStyle(e)[re(t)]}function ie(e,t,n){e.style[re(t)]=n}function fe(e,t){let n="";t.forEach(((e,t)=>n+=t+"("+e+") ")),ie(e,"transform",n)}const se={_default:{get:(e,t)=>ae(e,t),set(e,t,n){!function(e,t,n){e.style[re(t)]=oe(String(t),n)}(e,t,n)}}};function ce(e){return/rotate|skew/.test(e)?"deg":K[e]?"":"px"}function ue(e){const t=e.style.getPropertyValue(re("transform")),n=/(\w+)\(([^)]+)\)/g;let r;const o=[];for(;r=n.exec(t);)o.push([r[1],r[2]]);return o.sort(((e,t)=>W.indexOf(e[0])-W.indexOf(t[0]))),new Map(o)}function le(e){const t=[...e].sort(((e,t)=>W.indexOf(e[0])-W.indexOf(t[0])));e.clear(),t.forEach((([t,n])=>{e.set(t,n)}))}function de(e){var t;return(null==(t=g.exec(e))?void 0:t[3])||""}function ge(e,t,n){if(-1!==[de(String(t)),"deg","rad","turn"].indexOf(n))return t;const r=document.createElement(e.tagName);r.style.position="absolute",r.style.width=100+n;const o=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;o.appendChild(r);const a=100/r.offsetWidth;return o.removeChild(r),a*parseFloat(String(t))}function pe(e,t,n,r){switch(r){case"trans":return function(e,t,n){let r=ue(e).get(t)||(/scale/.test(t)?1:0+ce(t));return n?ge(e,r,n):r}(e,t,n);case"css":return function(e,t,n){let r=ae(e,t);return n&&b(r)?ge(e,r,n):r}(e,t,n);case"attr":return function(e,t){return e.getAttribute(t)}(e,t)}}function me(e,t){return function(e){return!!J[e]}(t)?"trans":re(t)?"css":!ee[t]&&e.hasAttribute(t)?"attr":""}["scrollTop","scrollLeft"].forEach((e=>{se[e]={get:(e,t)=>e[t],set(e,t,n){e[t]=n}}})),W.forEach((e=>{se[e]={get:(e,t)=>ue(e).get(t)||"",set(e,t,n){const r=ue(e);r.set(t,oe(t,n)),le(r),fe(e,r)}}}));const he={order:90,init(e){const{animatedTarget:t,prop:n,data:r}=e,o=t.target;if(function(e){return e instanceof HTMLElement||e instanceof SVGElement}(o)){const a=me(o,n);if(a){if(r.css=a,"trans"===a&&(t.transforms||(t.transforms={map:ue(o)})),e.withoutFrom){e.from=pe(o,n,e.unit,a);const t=g.exec(e.from);t&&(e.from=parseFloat(t[2]))}e.unit||(e.unit=ce(n))}}},update(e,t,n){const r=e.data.css;if(r){const{animatedTarget:o,prop:a,unit:i}=e,f=o.target;let s=x(t)?t[0]:t;switch("attr"!==r&&(s+=i),r){case"trans":let e=o.transforms.map;const t=e.has(a);e.set(a,s),t||le(e),fe(f,e);break;case"css":ie(f,a,s);break;case"attr":f.setAttribute(a,s)}return n}}},be={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"778899",lightslategrey:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};function ye(e){let t,n=/[0-9a-f]{2}/gi,r=[];for(;t=n.exec(e);)r.push(parseInt(t[0],16));return r}function we(e){let t,n=/[.\d]+/g,r=[];for(;t=n.exec(e);)r.push(+t[0]);return r}function xe(e){let t;if(e=String(e),/^#?[0-9a-f]{3}$/i.test(e))t=ye(e.replace(/(.)(.)(.)$/,"$1$1$2$2$3$3"));else if(/^#?([0-9a-f]{6})$/i.test(e))t=ye(RegExp.$1);else if(/^rgb/i.test(e))t=we(e);else if(/^hsl/i.test(e)){const n=we(e);n[0]/=360,n[1]/=100,n[2]/=100,t=function(e,t,n){let r,o,a;function i(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(0==t)r=o=a=n;else{let f=n<.5?n*(1+t):n+t-n*t,s=2*n-f;r=i(s,f,e+1/3),o=i(s,f,e),a=i(s,f,e-1/3)}return[Math.round(255*r),Math.round(255*o),Math.round(255*a)]}(...n).concat(n[3])}else t=be.hasOwnProperty(e=e.toLowerCase())?ye(be[e]):[0,0,0,1];return h(t[3])||(t[3]=1),t}const ke={order:80,init(e,t){if(b(e.to)&&(n=e.to,be.hasOwnProperty(String(n).toLowerCase())||/^(?:rgb|hsl|#(?:[0-9a-f]{6}|[0-9a-f]{3})$)/i.test(n))){const n=e.data,r=xe(String(e.from)),o=xe(e.to);return e.between=o.map(((e,t)=>({from:r[t],to:e,round:3===t?0:1}))),e.unit="",n.color={},t}var n},update(e,t){if(e.data.color)return"rgba("+t.join(",")+")"}};const ve={order:70,init(e){if(e.operator){let t=e.from;h(t)||(t=Number(t)||0),e.to=function(e,t,n){switch(n[0]){case"+":return e+t;case"-":return e-t;case"*":return e*t;case"/":return e/t;case"%":return e%t}return 0}(t,e.to,e.operator),e.from=t}}};function Me(e,t){return function(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}(e,t)/Math.PI*180}const Ee={order:60,init(e){const{data:t,to:n}=e;n instanceof q&&(t.svg=n,e.from=0,e.to=n.totalLength,e.unit="")},update(e,t){const n=e.data.svg;if(n){let e=function(e){return n.el.getPointAtLength(r+e)};const r=x(t)?t[0]:t,o=e(-1),a=e(0);switch(n.prop){case"x":return a.x+"px";case"y":return a.y+"px";case"angle":return Me(o,a)+"deg"}}}},Se={order:50,init(e){let t,n=e.to;if(b(n)&&(t=n.match(p))){e.data.interp=n.split(p);let r,o=e.from;b(o)&&(r=o.match(p))?o=r:x(o)||(o=[e.from]),e.from=o,e.to=t}},update(e,t){const n=e.data.interp;if(n)return t.map(((e,t)=>n[t]+e)).join("")}};I(Z),I(U),exports.colorPlugin=ke,exports.createAnimation=function(e,t,n){return G(n).add(e,t,n)},exports.createTimeline=G,exports.css=function e(t,n,r){if(y(n))for(let o in n)e(t,o,n[o]);else{if(void 0===r)return(se[n]&&se[n].get||se._default.get)(t,n);(se[n]&&se[n].set||se._default.set)(t,n,r)}},exports.cssPlugin=he,exports.easings=u,exports.geometry=function(e,t=100){return e=b(e)?document.querySelector(e):e,n=>new q(e,n,e.getTotalLength()*(t/100))},exports.getPrefixedCssProp=re,exports.interpPlugin=Se,exports.random=function(e,t){return Math.floor(Math.random()*(t-e+1)+e)},exports.relativePlugin=ve,exports.setDashoffset=e=>{if(e instanceof SVGGeometryElement){let t=e.getTotalLength();return e.setAttribute("stroke-dasharray",String(t)),t}return 0},exports.stagger=function(e,t){let{direction:n,grid:r,axis:o,from:a,start:i,easing:f}=Object.assign({},Q,t);f=v(f);let s=x(e);const[c,u]=s?e:[0,e];let l=[],d=0;return i=i||c,(e,t,g)=>{const p="center"===a,m="first"===a?0:p?(g-1)/2:"last"===a?g-1:a;if(!l.length){for(let e=0;e<g;e++){if(r){const[t,n]=r,a=(p?(n-1)/2:m%n)-e%n,i=(p?(t-1)/2:~~(m/n))-~~(e/n);let f=Math.sqrt(a*a+i*i);f="x"===o?-a:"y"===o?-i:f,l.push(f)}else l.push(Math.abs(m-e));d=Math.max(...l)}l=l.map((n=>f(e,t,g)(n/d)*d)),"reverse"===n&&(l=l.map((e=>o?-e:Math.abs(d-e))))}let h=s?(u-c)/d:u;return h===1/0&&(h=0),i+h*(Math.round(100*l[t])/100)}},exports.svgPlugin=Ee,exports.ticker=c,exports.use=I,exports.withFrom=function(e,t){return new S(e,t)};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* lwa 0.2.
|
|
1
|
+
/* lwa 0.2.3 | MIT license | https://github.com/sutras/lwa */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __pow = Math.pow;
|
|
4
4
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* lwa 0.2.
|
|
1
|
+
/* lwa 0.2.3 | MIT license | https://github.com/sutras/lwa */
|
|
2
2
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).lwa=t()}(this,(function(){"use strict";var e=Object.defineProperty,t=Math.pow,n=(t,n,r)=>((t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r)(t,"symbol"!=typeof n?n+"":n,r);const{request:r,cancel:o}=function(){if("function"==typeof requestAnimationFrame)return{request:requestAnimationFrame,cancel:cancelAnimationFrame};const e=[];let t,n=1,r=0;function o(){t=void 0;const n=e.slice();r+=e.length,e.length=0,n.forEach((e=>{0!==e&&e(Date.now())}))}return{request:r=>(e.push(r),t||(t=setTimeout(o,1e3/60)),n++),cancel(t){e[t-r]=0}}}(),a=new Set;let i=0,f=!0;function s(){0===a.size?f||(f=!0,o(i)):(new Set(a).forEach((e=>e())),i=r(s))}const c={add:function(e){a.add(e),f&&(f=!1,i=r(s))},remove:function(e){a.delete(e)}},u={linear:()=>e=>e},l={Sine:()=>e=>1-Math.cos(e*Math.PI/2),Expo:()=>e=>e?Math.pow(1024,e-1):0,Circ:()=>e=>1-Math.sqrt(1-e*e),Elastic:()=>e=>0===e||1===e?e:-Math.pow(2,10*e-10)*Math.sin(2*(10*e-10.75)*Math.PI/3),Back:()=>e=>{const t=1.70158;return e*e*((t+1)*e-t)},Bounce:()=>e=>{const t=7.5625,n=2.75;return 1-((e=1-e)<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375)}};["Quad","Cubic","Quart","Quint"].forEach(((e,t)=>{l[e]=()=>e=>Math.pow(e,t+2)})),Object.keys(l).forEach((e=>{const t=l[e];u["easeIn"+e]=t,u["easeOut"+e]=(e,n)=>r=>1-t(e,n)(1-r),u["easeInOut"+e]=(e,n)=>r=>r<.5?t(e,n)(2*r)/2:1-t(e,n)(2-2*r)/2}));const d=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/,g=new RegExp("^([+\\-*/%]=|)("+d.source+")("+/%|px|rpx|em|rem|vw|vh|deg|rad|turn|ex|ch|vmin|vmax|pc|pt|in|cm|mm/.source+"|)$","i"),p=new RegExp(d.source,"g"),m=new RegExp("^([<>]|)([+-]=|)("+d.source+"|)(%|)$");function h(e){return"number"==typeof e}function b(e){return"string"==typeof e}function y(e){return null!==e&&"object"==typeof e}function w(e){return"function"==typeof e}function k(e){return Array.isArray(e)}function v(e){return Array.isArray(e)?e:[e]}function x(e){return w(e)?e:()=>(u[e]||u.linear)(0,0)}const M=Symbol();class E{}class S extends E{constructor(e,t){super(),n(this,"from"),n(this,"to"),this.from=e,this.to=t}}class q extends E{constructor(e,t,r){super(),n(this,"el"),n(this,"prop"),n(this,"totalLength"),this.el=e,this.prop=t,this.totalLength=r}}const A=[];function O(e){const n=[];return k(e)||(e=[e]),e.flat().forEach((e=>{e&&(b(e)?n.push(...Array.from(document.querySelectorAll(e))):!function(e){let n;return y(e)&&Number.isInteger(n=e.length)&&n<t(2,32)}(e)?(y(e)||w(e))&&n.push(e):n.push(...Array.from(e)))})),Array.from(new Set(n))}function T(e,t){return w(e)?e(t.target,t.index,t.total):e}function C(e,t){const{duration:n,delay:r,begin:o,easing:a,between:i}=t;return i.map((t=>function(t){const{from:i,to:f,round:s}=t;let c=e<=o+r?i:e>=o+r+n?f:i+a((e-o-r)/n)*(f-i);return s&&(c=Math.round(c*s)/s),c}(t)))}function D(e,t){return k(e=T(e,t))?e.map((e=>D(e,t)[0])):((h(e)||b(e)||e instanceof E)&&(e={value:e}),[e])}function j(e,t,n,r,o,a,i){const f=t.length;let s,c=o||0;i=(null!=i?i:r.duration)/f;const u=t.map(((t,o)=>s=function(t,o,s){var u,l,d,p,m,h,y;const w=T(null!=(u=t.duration)?u:i,e),k=T(null!=(l=t.delay)?l:0===o?r.delay:0,e),v=T(null!=(d=t.endDelay)?d:o===f-1?r.endDelay:0,e),E=T(x(null!=(p=t.easing)?p:r.easing),e),q=T(null!=(m=t.round)?m:r.round,e),O=k+w+v,C=c,D=C+O;if(c+=O,!s){let e;s=(e=a[n])?e[e.length-1]:void 0}const j=t.value;let $,L;const P=j instanceof S;P?(L=T(j.from,e),$=T(j.to,e)):$=j,!P&&s&&(L=s.to);let I=!1;void 0===L&&(L=e.target[n],I=!0);let F="",N="";if(b($)){const e=g.exec($);e&&(F=e[1],$=parseFloat(e[2])||0,N=e[3])}const z={animatedTarget:e,prop:n,duration:w,delay:k,endDelay:v,begin:C,end:D,easing:E,data:{},from:L,to:$,withoutFrom:I,round:q,unit:N,operator:F,between:[]};for(let e=0,n=A.length;e<n&&(null==(y=(h=A[e]).init)?void 0:y.call(h,z,M))!==M;e++);return z}(t,o,s))).sort(((e,t)=>e.begin-t.begin));return{endTime:c,tweens:u}}function $(e,t,n){const r={},o=T(n.duration,e)/t.length;let a=0;return t.forEach((t=>{const i=function(e,t,n,r,o,a){let i={};for(let f in t){const s=t[f];null!=s&&(i[f]=j(e,D(s,e),f,n,r,o,a))}return i}(e,t,n,a,r,o);for(let e in i)a=Math.max(a,i[e].endTime),r[e]=(r[e]||[]).concat(i[e].tweens)})),r}function L(e,t,n){return e.map((e=>{const r=$(e,t,n);return Object.keys(r).map((e=>{return{seek:function(e){var n,r;let o;for(let a,i=0;a=t[i++];){if(a.begin<=e&&a.end>=e){o=a;break}e>a.end&&(!t[i+1]||t[i+1].begin>e)&&(o=a)}if(o){let t,a=C(e,o);for(let e=A.length-1;e>=0;e--){if(t=null==(r=(n=A[e]).update)?void 0:r.call(n,o,a,M),t===M)return;void 0!==t&&(a=t)}}},getDuration:function(){return Math.max(...t.map((e=>e.end)))},tweens:t=r[e]};var t}))})).flat()}const P={duration:500,delay:0,endDelay:0,easing:"easeInOutQuad",round:0};function I(e){v(e).forEach((e=>{A.includes(e)||(A.push(e),A.sort(((e,t)=>t.order-e.order)))}))}const F="alternate-reverse",N="reverse",z="alternate";function R(e){return e===N||e===F}function X(e){return e===z||e===F}const Y={externalTicker:!1,autoplay:!0,direction:"normal",loop:1},B=["begin","loopBegin","complete","loopComplete","pause","play","update"];function G(e){const t=Object.assign({},Y,e),{externalTicker:n,autoplay:r,direction:o,loop:a}=t;let i=!1,f=!0,s=0,u=0,l=a,d=R(o),g=0,p=[];const w=function(){const e={};function t(t,n){let r=e[t];r||(r=e[t]=new Set),r.add(n)}function n(t,n){if(n){const r=e[t];r&&(r.delete(n),0===r.size&&delete e[t])}else delete e[t]}return{on:t,off:n,once:function(e,r){t(e,(function t(...o){r(...o),n(e,t)}))},emit:function(t,...n){const r=e[t];r&&r.forEach((e=>{e(...n)}))}}}();function v(){return 0===l&&u===g}function x(e){let t=!1;e>=g?(e=g,t=!0):e<0&&(e=0),u=e;const n=d?g-u:u;p.forEach((({target:e,begin:t})=>{e.seek(n-t)})),w.emit("update",n,0===g?0:u/g),t&&(w.emit("loopComplete"),--l<0&&(l=0),0===l?(q(),w.emit("complete")):f||(X(o)&&(d=!d),E()))}function M(){if(!f){let e=Date.now();x(e-s+u),s=e}}function E(){i?u=0:(i=!0,w.emit("begin")),w.emit("loopBegin"),S()}function S(){i?f&&(f=!1,v()?(X(o)&&(d=!d),A()):(s=Date.now(),n||c.add(M),w.emit("play"))):E()}function q(){f||(f=!0,n||c.remove(M),w.emit("pause"))}function A(){q(),u=0,i=!1,l=a,d=R(o),S()}function T(e,t,n,r){if(function(e){return y(e)&&"getDuration"in e&&"seek"in e}(e)){let n=g;if(h(r=null!=t?t:">"))n=r;else{const{begin:e,end:t}=p[p.length-1]||{begin:0,end:0},o=t-e,[,a,i,f,s]=m.exec(r)||[,">","","",""];n="<"===a?e:">"===a?t:n;let c=+f;"%"===s&&(c=(a?o:g)/100*+f),n+="-="===i?-c:c}n=Math.max(0,n);const o=n+e.getDuration();p.push({target:e,position:r,begin:n,end:o}),g=Math.max(g,o)}else{(h(n)||b(n))&&(r=n,n=void 0);const o=function(e,t,n){const r=Object.assign({},P,n);return L((o=O(e)).map(((e,t)=>({target:e,index:t,total:o.length}))),k(t)?t:[t],r);var o}(e,t,n);o.forEach(((e,t)=>{T(e,0===t?r:"<")}))}return C}B.forEach((e=>{t[e]&&w.on(e,t[e])})),r&&0!==a&&E();const C={play:S,pause:q,finish:function(){v()||x(g)},restart:A,seek:x,progress:function(e){var t,n,r;x((r=1,((t=e)<(n=0)?n:t>r?r:t)*g))},tick:()=>{n&&M()},getPosition:()=>u,getDuration:()=>g,getProgress:()=>0===g?0:u/g,isReverse:()=>d,add:T,remove:function(e){const t=p.findIndex((t=>t.target===e));-1!==t&&(p.splice(t,1),function(){const e=[...p];p=[],g=0,e.forEach((e=>{T(e.target,e.position)}))}())},clear:function(){q(),g=0,p=[]},events:p,on:w.on,off:w.off,once:w.once};return C}const Q={start:0,from:0,direction:"normal",easing:"linear",grid:null,axis:null};const Z={order:100,update(e,t,n){const{animatedTarget:r,prop:o,unit:a}=e;let i=k(t)?t[0]:t;return a&&(i+=a),r.target[o]=i,n}},U={order:0,init(e,t){if(0===e.between.length){const n=v(e.to),r=v(e.from);return e.between=n.map(((t,n)=>({from:+r[n]||0,to:+t||0,round:e.round}))),t}}},V={},_=["","webkit","Moz"],H=document.documentElement,W=["translateX","translateY","translateZ","scale","scaleX","scaleY","scaleZ","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY","perspective"],J=te(W),K=te(["columnCount","fillOpacity","fontSizeAdjust","fontWeight","lineHeight","opacity","orphans","widows","zIndex","zoom","scale","scaleX","scaleY","scaleZ","order","flexGrow","flexShrink","scrollLeft","scrollTop","strokeDashoffset","strokeDasharray"]),ee=te(["value"]);function te(e){const t={};for(let n=0,r=e.length;n<r;n++)t[e[n]]=!0;return t}function ne(e){return e.replace(/[-]([^-])/g,((e,t)=>t.toUpperCase())).replace(/^./,(e=>e.toLowerCase()))}function re(e,t){if(V[e])return V[e];t=t||H.style;for(let n=0,r=_.length;n<r;n++){const t=_[n];let r=t?t+String(e).replace(/[-]([^-])/g,((e,t)=>t.toUpperCase())).replace(/^./,(e=>e.toUpperCase())):ne(String(e));if(r in H.style)return V[e]=r}return""}function oe(e,t){return t+(Number.isNaN(+t)||K[e]?"":"px")}function ae(e,t){return window.getComputedStyle(e)[re(t)]}function ie(e,t,n){e.style[re(t)]=n}function fe(e,t){let n="";t.forEach(((e,t)=>n+=t+"("+e+") ")),ie(e,"transform",n)}const se={_default:{get:(e,t)=>ae(e,t),set(e,t,n){!function(e,t,n){e.style[re(t)]=oe(String(t),n)}(e,t,n)}}};function ce(e){return/rotate|skew/.test(e)?"deg":K[e]?"":"px"}function ue(e){const t=e.style.getPropertyValue(re("transform")),n=/(\w+)\(([^)]+)\)/g;let r;const o=[];for(;r=n.exec(t);)o.push([r[1],r[2]]);return o.sort(((e,t)=>W.indexOf(e[0])-W.indexOf(t[0]))),new Map(o)}function le(e){const t=[...e].sort(((e,t)=>W.indexOf(e[0])-W.indexOf(t[0])));e.clear(),t.forEach((([t,n])=>{e.set(t,n)}))}function de(e){var t;return(null==(t=g.exec(e))?void 0:t[3])||""}function ge(e,t,n){if(-1!==[de(String(t)),"deg","rad","turn"].indexOf(n))return t;const r=document.createElement(e.tagName);r.style.position="absolute",r.style.width=100+n;const o=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;o.appendChild(r);const a=100/r.offsetWidth;return o.removeChild(r),a*parseFloat(String(t))}function pe(e,t,n,r){switch(r){case"trans":return function(e,t,n){let r=ue(e).get(t)||(/scale/.test(t)?1:0+ce(t));return n?ge(e,r,n):r}(e,t,n);case"css":return function(e,t,n){let r=ae(e,t);return n&&b(r)?ge(e,r,n):r}(e,t,n);case"attr":return function(e,t){return e.getAttribute(t)}(e,t)}}function me(e,t){return function(e){return!!J[e]}(t)?"trans":re(t)?"css":!ee[t]&&e.hasAttribute(t)?"attr":""}["scrollTop","scrollLeft"].forEach((e=>{se[e]={get:(e,t)=>e[t],set(e,t,n){e[t]=n}}})),W.forEach((e=>{se[e]={get:(e,t)=>ue(e).get(t)||"",set(e,t,n){const r=ue(e);r.set(t,oe(t,n)),le(r),fe(e,r)}}}));const he={order:90,init(e){const{animatedTarget:t,prop:n,data:r}=e,o=t.target;if(function(e){return e instanceof HTMLElement||e instanceof SVGElement}(o)){const a=me(o,n);if(a){if(r.css=a,"trans"===a&&(t.transforms||(t.transforms={map:ue(o)})),e.withoutFrom){e.from=pe(o,n,e.unit,a);const t=g.exec(e.from);t&&(e.from=parseFloat(t[2]))}e.unit||(e.unit=ce(n))}}},update(e,t,n){const r=e.data.css;if(r){const{animatedTarget:o,prop:a,unit:i}=e,f=o.target;let s=k(t)?t[0]:t;switch("attr"!==r&&(s+=i),r){case"trans":let e=o.transforms.map;const t=e.has(a);e.set(a,s),t||le(e),fe(f,e);break;case"css":ie(f,a,s);break;case"attr":f.setAttribute(a,s)}return n}}},be={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"778899",lightslategrey:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};function ye(e){let t,n=/[0-9a-f]{2}/gi,r=[];for(;t=n.exec(e);)r.push(parseInt(t[0],16));return r}function we(e){let t,n=/[.\d]+/g,r=[];for(;t=n.exec(e);)r.push(+t[0]);return r}function ke(e){let t;if(e=String(e),/^#?[0-9a-f]{3}$/i.test(e))t=ye(e.replace(/(.)(.)(.)$/,"$1$1$2$2$3$3"));else if(/^#?([0-9a-f]{6})$/i.test(e))t=ye(RegExp.$1);else if(/^rgb/i.test(e))t=we(e);else if(/^hsl/i.test(e)){const n=we(e);n[0]/=360,n[1]/=100,n[2]/=100,t=function(e,t,n){let r,o,a;function i(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(0==t)r=o=a=n;else{let f=n<.5?n*(1+t):n+t-n*t,s=2*n-f;r=i(s,f,e+1/3),o=i(s,f,e),a=i(s,f,e-1/3)}return[Math.round(255*r),Math.round(255*o),Math.round(255*a)]}(...n).concat(n[3])}else t=be.hasOwnProperty(e=e.toLowerCase())?ye(be[e]):[0,0,0,1];return h(t[3])||(t[3]=1),t}const ve={order:80,init(e,t){if(b(e.to)&&(n=e.to,be.hasOwnProperty(String(n).toLowerCase())||/^(?:rgb|hsl|#(?:[0-9a-f]{6}|[0-9a-f]{3})$)/i.test(n))){const n=e.data,r=ke(String(e.from)),o=ke(e.to);return e.between=o.map(((e,t)=>({from:r[t],to:e,round:3===t?0:1}))),e.unit="",n.color={},t}var n},update(e,t){if(e.data.color)return"rgba("+t.join(",")+")"}};const xe={order:70,init(e){if(e.operator){let t=e.from;h(t)||(t=Number(t)||0),e.to=function(e,t,n){switch(n[0]){case"+":return e+t;case"-":return e-t;case"*":return e*t;case"/":return e/t;case"%":return e%t}return 0}(t,e.to,e.operator),e.from=t}}};function Me(e,t){return function(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}(e,t)/Math.PI*180}const Ee={order:60,init(e){const{data:t,to:n}=e;n instanceof q&&(t.svg=n,e.from=0,e.to=n.totalLength,e.unit="")},update(e,t){const n=e.data.svg;if(n){let e=function(e){return n.el.getPointAtLength(r+e)};const r=k(t)?t[0]:t,o=e(-1),a=e(0);switch(n.prop){case"x":return a.x+"px";case"y":return a.y+"px";case"angle":return Me(o,a)+"deg"}}}},Se={order:50,init(e){let t,n=e.to;if(b(n)&&(t=n.match(p))){e.data.interp=n.split(p);let r,o=e.from;b(o)&&(r=o.match(p))?o=r:k(o)||(o=[e.from]),e.from=o,e.to=t}},update(e,t){const n=e.data.interp;if(n)return t.map(((e,t)=>n[t]+e)).join("")}};function qe(e,t,n){return G(n).add(e,t,n)}I(Z),I(U),I([he,ve,xe,Ee,Se]);const Ae=Object.assign(((...e)=>qe(...e)),{createAnimation:qe,createTimeline:G,ticker:c,stagger:function(e,t){let{direction:n,grid:r,axis:o,from:a,start:i,easing:f}=Object.assign({},Q,t);f=x(f);let s=k(e);const[c,u]=s?e:[0,e];let l=[],d=0;return i=i||c,(e,t,g)=>{const p="center"===a,m="first"===a?0:p?(g-1)/2:"last"===a?g-1:a;if(!l.length){for(let e=0;e<g;e++){if(r){const[t,n]=r,a=(p?(n-1)/2:m%n)-e%n,i=(p?(t-1)/2:~~(m/n))-~~(e/n);let f=Math.sqrt(a*a+i*i);f="x"===o?-a:"y"===o?-i:f,l.push(f)}else l.push(Math.abs(m-e));d=Math.max(...l)}l=l.map((n=>f(e,t,g)(n/d)*d)),"reverse"===n&&(l=l.map((e=>o?-e:Math.abs(d-e))))}let h=s?(u-c)/d:u;return h===1/0&&(h=0),i+h*(Math.round(100*l[t])/100)}},easings:u,withFrom:function(e,t){return new S(e,t)},random:function(e,t){return Math.floor(Math.random()*(t-e+1)+e)},use:I,css:function e(t,n,r){if(y(n))for(let o in n)e(t,o,n[o]);else{if(void 0===r)return(se[n]&&se[n].get||se._default.get)(t,n);(se[n]&&se[n].set||se._default.set)(t,n,r)}},getPrefixedCssProp:re,geometry:function(e,t=100){return e=b(e)?document.querySelector(e):e,n=>new q(e,n,e.getTotalLength()*(t/100))},setDashoffset:e=>{if(e instanceof SVGGeometryElement){let t=e.getTotalLength();return e.setAttribute("stroke-dasharray",String(t)),t}return 0},timeline:G});return Ae}));
|
package/dist/{lwa.js → lwa.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* lwa 0.2.
|
|
1
|
+
/* lwa 0.2.3 | MIT license | https://github.com/sutras/lwa */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __pow = Math.pow;
|
|
4
4
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
declare function add(tick: () => void): void;
|
|
2
|
+
|
|
3
|
+
declare interface AnimatedTarget {
|
|
4
|
+
target: object;
|
|
5
|
+
index: number;
|
|
6
|
+
total: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare type BaseValue = number | string;
|
|
10
|
+
|
|
11
|
+
declare interface Between {
|
|
12
|
+
from: number;
|
|
13
|
+
to: number;
|
|
14
|
+
round: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export declare function createAnimation(target: string | unknown[] | object, keyframes: Properties | Properties[], options?: TweenOptions & TimelineOptions): {
|
|
18
|
+
play: () => void;
|
|
19
|
+
pause: () => void;
|
|
20
|
+
finish: () => void;
|
|
21
|
+
restart: () => void;
|
|
22
|
+
seek: (nextPosition: number) => void;
|
|
23
|
+
progress: (p: number) => void;
|
|
24
|
+
tick: () => void;
|
|
25
|
+
getPosition(): number;
|
|
26
|
+
getDuration(): number;
|
|
27
|
+
getProgress(): number;
|
|
28
|
+
isReverse(): boolean;
|
|
29
|
+
add: {
|
|
30
|
+
(target: string | unknown[] | object, keyframes: Properties | Properties[], options?: TweenOptions, position?: number | string): any;
|
|
31
|
+
(target: string | unknown[] | object, keyframes: Properties | Properties[], position?: number | string): any;
|
|
32
|
+
(target: TimelineEventTarget, position?: number | string): any;
|
|
33
|
+
};
|
|
34
|
+
remove: (target: TimelineEventTarget) => void;
|
|
35
|
+
clear: () => void;
|
|
36
|
+
events: TimelineEvent[];
|
|
37
|
+
on: <U extends "pause" | "play" | "complete" | "update" | "begin" | "loopBegin" | "loopComplete">(type: U, callback: {
|
|
38
|
+
begin: () => void;
|
|
39
|
+
loopBegin: () => void;
|
|
40
|
+
complete: () => void;
|
|
41
|
+
loopComplete: () => void;
|
|
42
|
+
pause: () => void;
|
|
43
|
+
play: () => void;
|
|
44
|
+
update: (position: number, progress: number) => void;
|
|
45
|
+
}[U]) => void;
|
|
46
|
+
off: <U extends "pause" | "play" | "complete" | "update" | "begin" | "loopBegin" | "loopComplete">(type: U, callback?: {
|
|
47
|
+
begin: () => void;
|
|
48
|
+
loopBegin: () => void;
|
|
49
|
+
complete: () => void;
|
|
50
|
+
loopComplete: () => void;
|
|
51
|
+
pause: () => void;
|
|
52
|
+
play: () => void;
|
|
53
|
+
update: (position: number, progress: number) => void;
|
|
54
|
+
}[U] | undefined) => void;
|
|
55
|
+
once: <U extends "pause" | "play" | "complete" | "update" | "begin" | "loopBegin" | "loopComplete">(type: U, callback: {
|
|
56
|
+
begin: () => void;
|
|
57
|
+
loopBegin: () => void;
|
|
58
|
+
complete: () => void;
|
|
59
|
+
loopComplete: () => void;
|
|
60
|
+
pause: () => void;
|
|
61
|
+
play: () => void;
|
|
62
|
+
update: (position: number, progress: number) => void;
|
|
63
|
+
}[U]) => void;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export declare function createTimeline(options?: TimelineOptions): {
|
|
67
|
+
play: () => void;
|
|
68
|
+
pause: () => void;
|
|
69
|
+
finish: () => void;
|
|
70
|
+
restart: () => void;
|
|
71
|
+
seek: (nextPosition: number) => void;
|
|
72
|
+
progress: (p: number) => void;
|
|
73
|
+
tick: () => void;
|
|
74
|
+
getPosition(): number;
|
|
75
|
+
getDuration(): number;
|
|
76
|
+
getProgress(): number;
|
|
77
|
+
isReverse(): boolean;
|
|
78
|
+
add: {
|
|
79
|
+
(target: string | unknown[] | object, keyframes: Properties | Properties[], options?: TweenOptions, position?: number | string): any;
|
|
80
|
+
(target: string | unknown[] | object, keyframes: Properties | Properties[], position?: number | string): any;
|
|
81
|
+
(target: TimelineEventTarget, position?: number | string): any;
|
|
82
|
+
};
|
|
83
|
+
remove: (target: TimelineEventTarget) => void;
|
|
84
|
+
clear: () => void;
|
|
85
|
+
events: TimelineEvent[];
|
|
86
|
+
on: <U extends "pause" | "play" | "complete" | "update" | "begin" | "loopBegin" | "loopComplete">(type: U, callback: {
|
|
87
|
+
begin: () => void;
|
|
88
|
+
loopBegin: () => void;
|
|
89
|
+
complete: () => void;
|
|
90
|
+
loopComplete: () => void;
|
|
91
|
+
pause: () => void;
|
|
92
|
+
play: () => void;
|
|
93
|
+
update: (position: number, progress: number) => void;
|
|
94
|
+
}[U]) => void;
|
|
95
|
+
off: <U extends "pause" | "play" | "complete" | "update" | "begin" | "loopBegin" | "loopComplete">(type: U, callback?: {
|
|
96
|
+
begin: () => void;
|
|
97
|
+
loopBegin: () => void;
|
|
98
|
+
complete: () => void;
|
|
99
|
+
loopComplete: () => void;
|
|
100
|
+
pause: () => void;
|
|
101
|
+
play: () => void;
|
|
102
|
+
update: (position: number, progress: number) => void;
|
|
103
|
+
}[U] | undefined) => void;
|
|
104
|
+
once: <U extends "pause" | "play" | "complete" | "update" | "begin" | "loopBegin" | "loopComplete">(type: U, callback: {
|
|
105
|
+
begin: () => void;
|
|
106
|
+
loopBegin: () => void;
|
|
107
|
+
complete: () => void;
|
|
108
|
+
loopComplete: () => void;
|
|
109
|
+
pause: () => void;
|
|
110
|
+
play: () => void;
|
|
111
|
+
update: (position: number, progress: number) => void;
|
|
112
|
+
}[U]) => void;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
declare type Direction = "normal" | "reverse" | "alternate" | "alternate-reverse";
|
|
116
|
+
|
|
117
|
+
export declare type Easing = keyof typeof easings | FunctionalValue<(k: number) => number>;
|
|
118
|
+
|
|
119
|
+
export declare type Easings = {
|
|
120
|
+
linear: (...args: any[]) => (p: number) => number;
|
|
121
|
+
} & {
|
|
122
|
+
[p in EasingStuffNames as `${"easeIn" | "easeOut" | "easeInOut"}${p}`]: (...args: any[]) => (p: number) => number;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export declare const easings: Easings;
|
|
126
|
+
|
|
127
|
+
declare type EasingStuffNames = "Quad" | "Cubic" | "Quart" | "Quint" | "Sine" | "Expo" | "Circ" | "Elastic" | "Back" | "Bounce";
|
|
128
|
+
|
|
129
|
+
declare type FunctionalValue<T> = (target: object, index: number, total: number) => T;
|
|
130
|
+
|
|
131
|
+
declare type MayFunctionValue<T> = T | FunctionalValue<T>;
|
|
132
|
+
|
|
133
|
+
declare interface ObjectValue extends TweenOptions {
|
|
134
|
+
value: BaseValue | SpecialValue;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export declare interface Properties {
|
|
138
|
+
[p: string]: Value;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
declare function remove(tick: () => void): void;
|
|
142
|
+
|
|
143
|
+
declare type SingleValue = BaseValue | SpecialValue | ObjectValue;
|
|
144
|
+
|
|
145
|
+
declare class SpecialValue {
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export declare const ticker: {
|
|
149
|
+
add: typeof add;
|
|
150
|
+
remove: typeof remove;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export declare type Timeline = ReturnType<typeof createTimeline>;
|
|
154
|
+
|
|
155
|
+
declare interface TimelineCallbackOptions {
|
|
156
|
+
begin?: () => void;
|
|
157
|
+
loopBegin?: () => void;
|
|
158
|
+
complete?: () => void;
|
|
159
|
+
loopComplete?: () => void;
|
|
160
|
+
pause?: () => void;
|
|
161
|
+
play?: () => void;
|
|
162
|
+
update?: (position: number, progress: number) => void;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
declare interface TimelineEvent {
|
|
166
|
+
target: TimelineEventTarget;
|
|
167
|
+
position: number | string;
|
|
168
|
+
begin: number;
|
|
169
|
+
end: number;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
declare interface TimelineEventTarget {
|
|
173
|
+
getDuration: () => number;
|
|
174
|
+
seek: (position: number) => void;
|
|
175
|
+
tweens?: Tween[];
|
|
176
|
+
events?: TimelineEvent[];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export declare interface TimelineOptions extends TimelineCallbackOptions {
|
|
180
|
+
externalTicker?: boolean;
|
|
181
|
+
autoplay?: boolean;
|
|
182
|
+
direction?: Direction;
|
|
183
|
+
loop?: number;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
declare interface Tween<T extends {} = {}, U = {}> {
|
|
187
|
+
animatedTarget: AnimatedTarget & U;
|
|
188
|
+
prop: string;
|
|
189
|
+
duration: number;
|
|
190
|
+
delay: number;
|
|
191
|
+
endDelay: number;
|
|
192
|
+
begin: number;
|
|
193
|
+
end: number;
|
|
194
|
+
easing: (k: number) => number;
|
|
195
|
+
data: T;
|
|
196
|
+
from: unknown;
|
|
197
|
+
to: unknown;
|
|
198
|
+
withoutFrom: boolean;
|
|
199
|
+
round: number;
|
|
200
|
+
unit: string;
|
|
201
|
+
operator: string;
|
|
202
|
+
between: Between[];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export declare interface TweenOptions {
|
|
206
|
+
duration?: number | FunctionalValue<number>;
|
|
207
|
+
delay?: number | FunctionalValue<number>;
|
|
208
|
+
endDelay?: number | FunctionalValue<number>;
|
|
209
|
+
easing?: Easing;
|
|
210
|
+
round?: number | FunctionalValue<number>;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
declare type Value = MayFunctionValue<SingleValue | SingleValue[]>;
|
|
214
|
+
|
|
215
|
+
export declare function withFrom(from: MayFunctionValue<BaseValue>, to: MayFunctionValue<BaseValue>): WithFromValue;
|
|
216
|
+
|
|
217
|
+
declare class WithFromValue extends SpecialValue {
|
|
218
|
+
from: MayFunctionValue<BaseValue>;
|
|
219
|
+
to: MayFunctionValue<BaseValue>;
|
|
220
|
+
constructor(from: MayFunctionValue<BaseValue>, to: MayFunctionValue<BaseValue>);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export { }
|
package/dist/lwa.slim.js
ADDED
|
@@ -0,0 +1,749 @@
|
|
|
1
|
+
/* lwa 0.2.3 | MIT license | https://github.com/sutras/lwa */
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __pow = Math.pow;
|
|
4
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
+
function getAnimationFrameController() {
|
|
7
|
+
if (typeof requestAnimationFrame === "function") {
|
|
8
|
+
return {
|
|
9
|
+
request: requestAnimationFrame,
|
|
10
|
+
cancel: cancelAnimationFrame
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const fps = 60;
|
|
14
|
+
const callbacks = [];
|
|
15
|
+
let id2 = 1;
|
|
16
|
+
let cursor = 0;
|
|
17
|
+
let timer;
|
|
18
|
+
function playAll() {
|
|
19
|
+
timer = void 0;
|
|
20
|
+
const cloned = callbacks.slice();
|
|
21
|
+
cursor += callbacks.length;
|
|
22
|
+
callbacks.length = 0;
|
|
23
|
+
cloned.forEach((callback) => {
|
|
24
|
+
if (callback !== 0) {
|
|
25
|
+
callback(Date.now());
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
request(handler) {
|
|
31
|
+
callbacks.push(handler);
|
|
32
|
+
if (!timer) {
|
|
33
|
+
timer = setTimeout(playAll, 1e3 / fps);
|
|
34
|
+
}
|
|
35
|
+
return id2++;
|
|
36
|
+
},
|
|
37
|
+
cancel(id22) {
|
|
38
|
+
callbacks[id22 - cursor] = 0;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const { request, cancel } = getAnimationFrameController();
|
|
43
|
+
const ticks = /* @__PURE__ */ new Set();
|
|
44
|
+
let id = 0;
|
|
45
|
+
let paused = true;
|
|
46
|
+
function add(tick) {
|
|
47
|
+
ticks.add(tick);
|
|
48
|
+
run();
|
|
49
|
+
}
|
|
50
|
+
function remove(tick) {
|
|
51
|
+
ticks.delete(tick);
|
|
52
|
+
}
|
|
53
|
+
function step() {
|
|
54
|
+
if (ticks.size === 0) {
|
|
55
|
+
stop();
|
|
56
|
+
} else {
|
|
57
|
+
new Set(ticks).forEach((tick) => tick());
|
|
58
|
+
id = request(step);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function run() {
|
|
62
|
+
if (paused) {
|
|
63
|
+
paused = false;
|
|
64
|
+
id = request(step);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function stop() {
|
|
68
|
+
if (!paused) {
|
|
69
|
+
paused = true;
|
|
70
|
+
cancel(id);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const ticker = {
|
|
74
|
+
add,
|
|
75
|
+
remove
|
|
76
|
+
};
|
|
77
|
+
const easings = {
|
|
78
|
+
linear: () => (p) => p
|
|
79
|
+
};
|
|
80
|
+
const easingStuff = {
|
|
81
|
+
Sine: () => (p) => 1 - Math.cos(p * Math.PI / 2),
|
|
82
|
+
Expo: () => (p) => p ? Math.pow(1024, p - 1) : 0,
|
|
83
|
+
Circ: () => (p) => 1 - Math.sqrt(1 - p * p),
|
|
84
|
+
Elastic: () => (p) => p === 0 || p === 1 ? p : -Math.pow(2, 10 * p - 10) * Math.sin((p * 10 - 10.75) * 2 * Math.PI / 3),
|
|
85
|
+
Back: () => (p) => {
|
|
86
|
+
const s = 1.70158;
|
|
87
|
+
return p * p * ((s + 1) * p - s);
|
|
88
|
+
},
|
|
89
|
+
Bounce: () => (p) => {
|
|
90
|
+
p = 1 - p;
|
|
91
|
+
const s = 7.5625;
|
|
92
|
+
const k = 2.75;
|
|
93
|
+
return 1 - (p < 1 / k ? s * p * p : p < 2 / k ? s * (p -= 1.5 / k) * p + 0.75 : p < 2.5 / k ? s * (p -= 2.25 / k) * p + 0.9375 : s * (p -= 2.625 / k) * p + 0.984375);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const powerNames = ["Quad", "Cubic", "Quart", "Quint"];
|
|
97
|
+
powerNames.forEach((name, i) => {
|
|
98
|
+
easingStuff[name] = () => (p) => Math.pow(p, i + 2);
|
|
99
|
+
});
|
|
100
|
+
Object.keys(easingStuff).forEach((name) => {
|
|
101
|
+
const easeIn = easingStuff[name];
|
|
102
|
+
easings["easeIn" + name] = easeIn;
|
|
103
|
+
easings["easeOut" + name] = (a, b) => (p) => 1 - easeIn(a, b)(1 - p);
|
|
104
|
+
easings["easeInOut" + name] = (a, b) => (p) => p < 0.5 ? easeIn(a, b)(p * 2) / 2 : 1 - easeIn(a, b)(2 - 2 * p) / 2;
|
|
105
|
+
});
|
|
106
|
+
const rNum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/;
|
|
107
|
+
const rUnit = /%|px|rpx|em|rem|vw|vh|deg|rad|turn|ex|ch|vmin|vmax|pc|pt|in|cm|mm/;
|
|
108
|
+
const rCssNumVal = new RegExp(
|
|
109
|
+
"^([+\\-*/%]=|)(" + rNum.source + ")(" + rUnit.source + "|)$",
|
|
110
|
+
"i"
|
|
111
|
+
);
|
|
112
|
+
const rTimelinePos = new RegExp(
|
|
113
|
+
"^([<>]|)([+-]=|)(" + rNum.source + "|)(%|)$"
|
|
114
|
+
);
|
|
115
|
+
function isNumber(target) {
|
|
116
|
+
return typeof target === "number";
|
|
117
|
+
}
|
|
118
|
+
function isString(target) {
|
|
119
|
+
return typeof target === "string";
|
|
120
|
+
}
|
|
121
|
+
function isObject(target) {
|
|
122
|
+
return target !== null && typeof target === "object";
|
|
123
|
+
}
|
|
124
|
+
function isFunction(target) {
|
|
125
|
+
return typeof target === "function";
|
|
126
|
+
}
|
|
127
|
+
function isArrayLike(target) {
|
|
128
|
+
let l;
|
|
129
|
+
return isObject(target) && Number.isInteger(l = target.length) && l < __pow(2, 32);
|
|
130
|
+
}
|
|
131
|
+
function isArray(target) {
|
|
132
|
+
return Array.isArray(target);
|
|
133
|
+
}
|
|
134
|
+
function minmax(n, min, max) {
|
|
135
|
+
return n < min ? min : n > max ? max : n;
|
|
136
|
+
}
|
|
137
|
+
function toArray(target) {
|
|
138
|
+
return Array.isArray(target) ? target : [target];
|
|
139
|
+
}
|
|
140
|
+
const defaultEasing = "easeInOutQuad";
|
|
141
|
+
function getEasing(ease) {
|
|
142
|
+
return isFunction(ease) ? ease : () => (easings[ease] || easings.linear)(0, 0);
|
|
143
|
+
}
|
|
144
|
+
function createEmitter() {
|
|
145
|
+
const events = {};
|
|
146
|
+
function on(type, callback) {
|
|
147
|
+
let callbacks = events[type];
|
|
148
|
+
if (!callbacks) {
|
|
149
|
+
callbacks = events[type] = /* @__PURE__ */ new Set();
|
|
150
|
+
}
|
|
151
|
+
callbacks.add(callback);
|
|
152
|
+
}
|
|
153
|
+
function off(type, callback) {
|
|
154
|
+
if (callback) {
|
|
155
|
+
const callbacks = events[type];
|
|
156
|
+
if (callbacks) {
|
|
157
|
+
callbacks.delete(callback);
|
|
158
|
+
if (callbacks.size === 0) {
|
|
159
|
+
delete events[type];
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
delete events[type];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function once(type, callback) {
|
|
167
|
+
on(type, function fn(...args) {
|
|
168
|
+
callback(...args);
|
|
169
|
+
off(type, fn);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function emit(type, ...args) {
|
|
173
|
+
const callbacks = events[type];
|
|
174
|
+
if (callbacks) {
|
|
175
|
+
callbacks.forEach((callback) => {
|
|
176
|
+
callback(...args);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
on,
|
|
182
|
+
off,
|
|
183
|
+
once,
|
|
184
|
+
emit
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
const TERMINATE = Symbol();
|
|
188
|
+
class SpecialValue {
|
|
189
|
+
}
|
|
190
|
+
class WithFromValue extends SpecialValue {
|
|
191
|
+
constructor(from, to) {
|
|
192
|
+
super();
|
|
193
|
+
__publicField(this, "from");
|
|
194
|
+
__publicField(this, "to");
|
|
195
|
+
this.from = from;
|
|
196
|
+
this.to = to;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const plugins = [];
|
|
200
|
+
function parseTarget(target) {
|
|
201
|
+
const result = [];
|
|
202
|
+
if (!isArray(target)) {
|
|
203
|
+
target = [target];
|
|
204
|
+
}
|
|
205
|
+
target.flat().forEach((item) => {
|
|
206
|
+
if (item) {
|
|
207
|
+
if (isString(item)) {
|
|
208
|
+
result.push(...Array.from(document.querySelectorAll(item)));
|
|
209
|
+
} else if (isArrayLike(item)) {
|
|
210
|
+
result.push(...Array.from(item));
|
|
211
|
+
} else if (isObject(item) || isFunction(item)) {
|
|
212
|
+
result.push(item);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
return Array.from(new Set(result));
|
|
217
|
+
}
|
|
218
|
+
function getFuncValue(value, animatedTarget) {
|
|
219
|
+
return isFunction(value) ? value(animatedTarget.target, animatedTarget.index, animatedTarget.total) : value;
|
|
220
|
+
}
|
|
221
|
+
function getTweenValue(position, tween) {
|
|
222
|
+
const { duration, delay, begin, easing, between } = tween;
|
|
223
|
+
function getBetweenValue(between2) {
|
|
224
|
+
const { from, to, round } = between2;
|
|
225
|
+
let value = position <= begin + delay ? from : position >= begin + delay + duration ? to : from + easing((position - begin - delay) / duration) * (to - from);
|
|
226
|
+
if (round) {
|
|
227
|
+
value = Math.round(value * round) / round;
|
|
228
|
+
}
|
|
229
|
+
return value;
|
|
230
|
+
}
|
|
231
|
+
return between.map((item) => getBetweenValue(item));
|
|
232
|
+
}
|
|
233
|
+
function getAnimatedTargets(targets) {
|
|
234
|
+
return targets.map((target, i) => ({
|
|
235
|
+
target,
|
|
236
|
+
index: i,
|
|
237
|
+
total: targets.length
|
|
238
|
+
}));
|
|
239
|
+
}
|
|
240
|
+
function structureValue(value, animatedTarget) {
|
|
241
|
+
value = getFuncValue(value, animatedTarget);
|
|
242
|
+
if (isArray(value)) {
|
|
243
|
+
return value.map((value2) => structureValue(value2, animatedTarget)[0]);
|
|
244
|
+
}
|
|
245
|
+
if (isNumber(value) || isString(value) || value instanceof SpecialValue) {
|
|
246
|
+
value = { value };
|
|
247
|
+
}
|
|
248
|
+
return [value];
|
|
249
|
+
}
|
|
250
|
+
function normalizeTweens(animatedTarget, objectValues, prop, options, beginTime, animationProperties, averageDuration) {
|
|
251
|
+
const l = objectValues.length;
|
|
252
|
+
let endTime = beginTime || 0;
|
|
253
|
+
let prevTween;
|
|
254
|
+
averageDuration = (averageDuration != null ? averageDuration : options.duration) / l;
|
|
255
|
+
function normalizeTween(objectValue, index, prevTween2) {
|
|
256
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
257
|
+
const duration = getFuncValue(
|
|
258
|
+
(_a = objectValue.duration) != null ? _a : averageDuration,
|
|
259
|
+
animatedTarget
|
|
260
|
+
);
|
|
261
|
+
const delay = getFuncValue(
|
|
262
|
+
(_b = objectValue.delay) != null ? _b : index === 0 ? options.delay : 0,
|
|
263
|
+
animatedTarget
|
|
264
|
+
);
|
|
265
|
+
const endDelay = getFuncValue(
|
|
266
|
+
(_c = objectValue.endDelay) != null ? _c : index === l - 1 ? options.endDelay : 0,
|
|
267
|
+
animatedTarget
|
|
268
|
+
);
|
|
269
|
+
const easing = getFuncValue(
|
|
270
|
+
getEasing((_d = objectValue.easing) != null ? _d : options.easing),
|
|
271
|
+
animatedTarget
|
|
272
|
+
);
|
|
273
|
+
const round = getFuncValue(
|
|
274
|
+
(_e = objectValue.round) != null ? _e : options.round,
|
|
275
|
+
animatedTarget
|
|
276
|
+
);
|
|
277
|
+
const total = delay + duration + endDelay;
|
|
278
|
+
const begin = endTime;
|
|
279
|
+
const end = begin + total;
|
|
280
|
+
endTime += total;
|
|
281
|
+
if (!prevTween2) {
|
|
282
|
+
let values;
|
|
283
|
+
prevTween2 = (values = animationProperties[prop]) ? values[values.length - 1] : void 0;
|
|
284
|
+
}
|
|
285
|
+
const value = objectValue.value;
|
|
286
|
+
let to;
|
|
287
|
+
let from;
|
|
288
|
+
const withFromValue = value instanceof WithFromValue;
|
|
289
|
+
if (withFromValue) {
|
|
290
|
+
from = getFuncValue(value.from, animatedTarget);
|
|
291
|
+
to = getFuncValue(value.to, animatedTarget);
|
|
292
|
+
} else {
|
|
293
|
+
to = value;
|
|
294
|
+
}
|
|
295
|
+
if (!withFromValue && prevTween2) {
|
|
296
|
+
from = prevTween2.to;
|
|
297
|
+
}
|
|
298
|
+
let withoutFrom = false;
|
|
299
|
+
if (from === void 0) {
|
|
300
|
+
from = animatedTarget.target[prop];
|
|
301
|
+
withoutFrom = true;
|
|
302
|
+
}
|
|
303
|
+
let operator = "";
|
|
304
|
+
let unit = "";
|
|
305
|
+
if (isString(to)) {
|
|
306
|
+
const parts = rCssNumVal.exec(to);
|
|
307
|
+
if (parts) {
|
|
308
|
+
operator = parts[1];
|
|
309
|
+
to = parseFloat(parts[2]) || 0;
|
|
310
|
+
unit = parts[3];
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
const tween = {
|
|
314
|
+
animatedTarget,
|
|
315
|
+
prop,
|
|
316
|
+
duration,
|
|
317
|
+
delay,
|
|
318
|
+
endDelay,
|
|
319
|
+
begin,
|
|
320
|
+
end,
|
|
321
|
+
easing,
|
|
322
|
+
data: {},
|
|
323
|
+
from,
|
|
324
|
+
to,
|
|
325
|
+
withoutFrom,
|
|
326
|
+
round,
|
|
327
|
+
unit,
|
|
328
|
+
operator,
|
|
329
|
+
between: []
|
|
330
|
+
};
|
|
331
|
+
for (let i = 0, l2 = plugins.length; i < l2; i++) {
|
|
332
|
+
const retValue = (_g = (_f = plugins[i]).init) == null ? void 0 : _g.call(_f, tween, TERMINATE);
|
|
333
|
+
if (retValue === TERMINATE) {
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return tween;
|
|
338
|
+
}
|
|
339
|
+
const tweens = objectValues.map(
|
|
340
|
+
(objectValue, index) => prevTween = normalizeTween(objectValue, index, prevTween)
|
|
341
|
+
).sort((a, b) => a.begin - b.begin);
|
|
342
|
+
return {
|
|
343
|
+
endTime,
|
|
344
|
+
tweens
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function getOneKeyframeTween(animatedTarget, properties, options, beginTime, animationProperties, averageDuration) {
|
|
348
|
+
let props = {};
|
|
349
|
+
for (let p in properties) {
|
|
350
|
+
const value = properties[p];
|
|
351
|
+
if (value !== null && value !== void 0) {
|
|
352
|
+
props[p] = normalizeTweens(
|
|
353
|
+
animatedTarget,
|
|
354
|
+
structureValue(value, animatedTarget),
|
|
355
|
+
p,
|
|
356
|
+
options,
|
|
357
|
+
beginTime,
|
|
358
|
+
animationProperties,
|
|
359
|
+
averageDuration
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return props;
|
|
364
|
+
}
|
|
365
|
+
function getAnimationProperties(animatedTarget, keyframes, options) {
|
|
366
|
+
const animationProperties = {};
|
|
367
|
+
const averageDuration = getFuncValue(options.duration, animatedTarget) / keyframes.length;
|
|
368
|
+
let endTime = 0;
|
|
369
|
+
keyframes.forEach((properties) => {
|
|
370
|
+
const oneKeyframeTween = getOneKeyframeTween(
|
|
371
|
+
animatedTarget,
|
|
372
|
+
properties,
|
|
373
|
+
options,
|
|
374
|
+
endTime,
|
|
375
|
+
animationProperties,
|
|
376
|
+
averageDuration
|
|
377
|
+
);
|
|
378
|
+
for (let p in oneKeyframeTween) {
|
|
379
|
+
endTime = Math.max(endTime, oneKeyframeTween[p].endTime);
|
|
380
|
+
animationProperties[p] = (animationProperties[p] || []).concat(
|
|
381
|
+
oneKeyframeTween[p].tweens
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
return animationProperties;
|
|
386
|
+
}
|
|
387
|
+
function createAnimation$1(tweens) {
|
|
388
|
+
function seek(position) {
|
|
389
|
+
var _a, _b;
|
|
390
|
+
let currTween;
|
|
391
|
+
for (let i = 0, tween; tween = tweens[i++]; ) {
|
|
392
|
+
if (tween.begin <= position && tween.end >= position) {
|
|
393
|
+
currTween = tween;
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
if (position > tween.end) {
|
|
397
|
+
if (!tweens[i + 1] || tweens[i + 1].begin > position) {
|
|
398
|
+
currTween = tween;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (currTween) {
|
|
403
|
+
let value = getTweenValue(position, currTween);
|
|
404
|
+
let currentValue;
|
|
405
|
+
for (let i = plugins.length - 1; i >= 0; i--) {
|
|
406
|
+
currentValue = (_b = (_a = plugins[i]).update) == null ? void 0 : _b.call(_a, currTween, value, TERMINATE);
|
|
407
|
+
if (currentValue === TERMINATE) {
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
if (currentValue !== void 0) {
|
|
411
|
+
value = currentValue;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
function getDuration() {
|
|
417
|
+
return Math.max(...tweens.map((tween) => tween.end));
|
|
418
|
+
}
|
|
419
|
+
return {
|
|
420
|
+
seek,
|
|
421
|
+
getDuration,
|
|
422
|
+
tweens
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
function getAnimations(animationTargets, keyframes, options) {
|
|
426
|
+
return animationTargets.map((animatedTarget) => {
|
|
427
|
+
const animationProperties = getAnimationProperties(
|
|
428
|
+
animatedTarget,
|
|
429
|
+
keyframes,
|
|
430
|
+
options
|
|
431
|
+
);
|
|
432
|
+
return Object.keys(animationProperties).map(
|
|
433
|
+
(p) => createAnimation$1(animationProperties[p])
|
|
434
|
+
);
|
|
435
|
+
}).flat();
|
|
436
|
+
}
|
|
437
|
+
const defaultTweenOptions = {
|
|
438
|
+
duration: 500,
|
|
439
|
+
delay: 0,
|
|
440
|
+
endDelay: 0,
|
|
441
|
+
easing: defaultEasing,
|
|
442
|
+
round: 0
|
|
443
|
+
};
|
|
444
|
+
function createAnimations(target, keyframes, options) {
|
|
445
|
+
const tweenOptions = Object.assign({}, defaultTweenOptions, options);
|
|
446
|
+
return getAnimations(
|
|
447
|
+
getAnimatedTargets(parseTarget(target)),
|
|
448
|
+
isArray(keyframes) ? keyframes : [keyframes],
|
|
449
|
+
tweenOptions
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
function withFrom(from, to) {
|
|
453
|
+
return new WithFromValue(from, to);
|
|
454
|
+
}
|
|
455
|
+
function use(plugin) {
|
|
456
|
+
toArray(plugin).forEach((plugin2) => {
|
|
457
|
+
if (!plugins.includes(plugin2)) {
|
|
458
|
+
plugins.push(plugin2);
|
|
459
|
+
plugins.sort((a, b) => b.order - a.order);
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
const DIRECTION_ALTERNATE_REVERSE = "alternate-reverse";
|
|
464
|
+
const DIRECTION_REVERSE = "reverse";
|
|
465
|
+
const DIRECTION_ALTERNATE = "alternate";
|
|
466
|
+
function isReverse(direction) {
|
|
467
|
+
return direction === DIRECTION_REVERSE || direction === DIRECTION_ALTERNATE_REVERSE;
|
|
468
|
+
}
|
|
469
|
+
function isAlternate(direction) {
|
|
470
|
+
return direction === DIRECTION_ALTERNATE || direction === DIRECTION_ALTERNATE_REVERSE;
|
|
471
|
+
}
|
|
472
|
+
function isTimelineEventTarget(target) {
|
|
473
|
+
return isObject(target) && "getDuration" in target && "seek" in target;
|
|
474
|
+
}
|
|
475
|
+
const defaultTimelineOptions = {
|
|
476
|
+
externalTicker: false,
|
|
477
|
+
autoplay: true,
|
|
478
|
+
direction: "normal",
|
|
479
|
+
loop: 1
|
|
480
|
+
};
|
|
481
|
+
const callbackNames = [
|
|
482
|
+
"begin",
|
|
483
|
+
"loopBegin",
|
|
484
|
+
"complete",
|
|
485
|
+
"loopComplete",
|
|
486
|
+
"pause",
|
|
487
|
+
"play",
|
|
488
|
+
"update"
|
|
489
|
+
];
|
|
490
|
+
function createTimeline(options) {
|
|
491
|
+
const mergedOptions = Object.assign({}, defaultTimelineOptions, options);
|
|
492
|
+
const { externalTicker, autoplay, direction, loop } = mergedOptions;
|
|
493
|
+
let firstTime = false;
|
|
494
|
+
let paused2 = true;
|
|
495
|
+
let prevTickTime = 0;
|
|
496
|
+
let position = 0;
|
|
497
|
+
let currentLoop = loop;
|
|
498
|
+
let reverse = isReverse(direction);
|
|
499
|
+
let duration = 0;
|
|
500
|
+
let events = [];
|
|
501
|
+
const emitter = createEmitter();
|
|
502
|
+
callbackNames.forEach((name) => {
|
|
503
|
+
if (mergedOptions[name]) {
|
|
504
|
+
emitter.on(name, mergedOptions[name]);
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
function isCompleted() {
|
|
508
|
+
return currentLoop === 0 && position === duration;
|
|
509
|
+
}
|
|
510
|
+
function seek(nextPosition) {
|
|
511
|
+
let finished = false;
|
|
512
|
+
if (nextPosition >= duration) {
|
|
513
|
+
nextPosition = duration;
|
|
514
|
+
finished = true;
|
|
515
|
+
} else if (nextPosition < 0) {
|
|
516
|
+
nextPosition = 0;
|
|
517
|
+
}
|
|
518
|
+
position = nextPosition;
|
|
519
|
+
const seekPosition = reverse ? duration - position : position;
|
|
520
|
+
events.forEach(({ target, begin }) => {
|
|
521
|
+
target.seek(seekPosition - begin);
|
|
522
|
+
});
|
|
523
|
+
emitter.emit(
|
|
524
|
+
"update",
|
|
525
|
+
seekPosition,
|
|
526
|
+
duration === 0 ? 0 : position / duration
|
|
527
|
+
);
|
|
528
|
+
if (finished) {
|
|
529
|
+
emitter.emit("loopComplete");
|
|
530
|
+
if (--currentLoop < 0) {
|
|
531
|
+
currentLoop = 0;
|
|
532
|
+
}
|
|
533
|
+
if (currentLoop === 0) {
|
|
534
|
+
pause();
|
|
535
|
+
emitter.emit("complete");
|
|
536
|
+
} else {
|
|
537
|
+
if (!paused2) {
|
|
538
|
+
if (isAlternate(direction)) {
|
|
539
|
+
reverse = !reverse;
|
|
540
|
+
}
|
|
541
|
+
start();
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
function progress(p) {
|
|
547
|
+
seek(minmax(p, 0, 1) * duration);
|
|
548
|
+
}
|
|
549
|
+
function tick() {
|
|
550
|
+
if (!paused2) {
|
|
551
|
+
let currTime = Date.now();
|
|
552
|
+
seek(currTime - prevTickTime + position);
|
|
553
|
+
prevTickTime = currTime;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
function start() {
|
|
557
|
+
if (!firstTime) {
|
|
558
|
+
firstTime = true;
|
|
559
|
+
emitter.emit("begin");
|
|
560
|
+
} else {
|
|
561
|
+
position = 0;
|
|
562
|
+
}
|
|
563
|
+
emitter.emit("loopBegin");
|
|
564
|
+
play();
|
|
565
|
+
}
|
|
566
|
+
function play() {
|
|
567
|
+
if (!firstTime) {
|
|
568
|
+
start();
|
|
569
|
+
} else {
|
|
570
|
+
if (paused2) {
|
|
571
|
+
paused2 = false;
|
|
572
|
+
if (isCompleted()) {
|
|
573
|
+
if (isAlternate(direction)) {
|
|
574
|
+
reverse = !reverse;
|
|
575
|
+
}
|
|
576
|
+
restart();
|
|
577
|
+
} else {
|
|
578
|
+
prevTickTime = Date.now();
|
|
579
|
+
if (!externalTicker) {
|
|
580
|
+
ticker.add(tick);
|
|
581
|
+
}
|
|
582
|
+
emitter.emit("play");
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
function pause() {
|
|
588
|
+
if (!paused2) {
|
|
589
|
+
paused2 = true;
|
|
590
|
+
if (!externalTicker) {
|
|
591
|
+
ticker.remove(tick);
|
|
592
|
+
}
|
|
593
|
+
emitter.emit("pause");
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
function restart() {
|
|
597
|
+
pause();
|
|
598
|
+
position = 0;
|
|
599
|
+
firstTime = false;
|
|
600
|
+
currentLoop = loop;
|
|
601
|
+
reverse = isReverse(direction);
|
|
602
|
+
play();
|
|
603
|
+
}
|
|
604
|
+
function finish() {
|
|
605
|
+
if (!isCompleted()) {
|
|
606
|
+
seek(duration);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
function add2(target, positionOrKeyframes, optionsOrPosition, position2) {
|
|
610
|
+
if (isTimelineEventTarget(target)) {
|
|
611
|
+
position2 = positionOrKeyframes != null ? positionOrKeyframes : ">";
|
|
612
|
+
let begin = duration;
|
|
613
|
+
if (isNumber(position2)) {
|
|
614
|
+
begin = position2;
|
|
615
|
+
} else {
|
|
616
|
+
const { begin: prevBegin, end: prevEnd } = events[events.length - 1] || {
|
|
617
|
+
begin: 0,
|
|
618
|
+
end: 0
|
|
619
|
+
};
|
|
620
|
+
const prevDuration = prevEnd - prevBegin;
|
|
621
|
+
const [, bracket, relative, num, unit] = rTimelinePos.exec(
|
|
622
|
+
position2
|
|
623
|
+
) || [, ">", "", "", ""];
|
|
624
|
+
begin = bracket === "<" ? prevBegin : bracket === ">" ? prevEnd : begin;
|
|
625
|
+
let value = +num;
|
|
626
|
+
if (unit === "%") {
|
|
627
|
+
value = (bracket ? prevDuration : duration) / 100 * +num;
|
|
628
|
+
}
|
|
629
|
+
begin += relative === "-=" ? -value : value;
|
|
630
|
+
}
|
|
631
|
+
begin = Math.max(0, begin);
|
|
632
|
+
const end = begin + target.getDuration();
|
|
633
|
+
events.push({ target, position: position2, begin, end });
|
|
634
|
+
duration = Math.max(duration, end);
|
|
635
|
+
} else {
|
|
636
|
+
if (isNumber(optionsOrPosition) || isString(optionsOrPosition)) {
|
|
637
|
+
position2 = optionsOrPosition;
|
|
638
|
+
optionsOrPosition = void 0;
|
|
639
|
+
}
|
|
640
|
+
const animations = createAnimations(
|
|
641
|
+
target,
|
|
642
|
+
positionOrKeyframes,
|
|
643
|
+
optionsOrPosition
|
|
644
|
+
);
|
|
645
|
+
animations.forEach((animation, index) => {
|
|
646
|
+
add2(animation, index === 0 ? position2 : "<");
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
return timeline;
|
|
650
|
+
}
|
|
651
|
+
function remove2(target) {
|
|
652
|
+
const index = events.findIndex((e) => e.target === target);
|
|
653
|
+
if (index !== -1) {
|
|
654
|
+
events.splice(index, 1);
|
|
655
|
+
update();
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
function update() {
|
|
659
|
+
const oldEvents = [...events];
|
|
660
|
+
events = [];
|
|
661
|
+
duration = 0;
|
|
662
|
+
oldEvents.forEach((event) => {
|
|
663
|
+
add2(event.target, event.position);
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
function clear() {
|
|
667
|
+
pause();
|
|
668
|
+
duration = 0;
|
|
669
|
+
events = [];
|
|
670
|
+
}
|
|
671
|
+
if (autoplay && loop !== 0) {
|
|
672
|
+
start();
|
|
673
|
+
}
|
|
674
|
+
const timeline = {
|
|
675
|
+
play,
|
|
676
|
+
pause,
|
|
677
|
+
finish,
|
|
678
|
+
restart,
|
|
679
|
+
seek,
|
|
680
|
+
progress,
|
|
681
|
+
tick: () => {
|
|
682
|
+
if (externalTicker) {
|
|
683
|
+
tick();
|
|
684
|
+
}
|
|
685
|
+
},
|
|
686
|
+
getPosition() {
|
|
687
|
+
return position;
|
|
688
|
+
},
|
|
689
|
+
getDuration() {
|
|
690
|
+
return duration;
|
|
691
|
+
},
|
|
692
|
+
getProgress() {
|
|
693
|
+
return duration === 0 ? 0 : position / duration;
|
|
694
|
+
},
|
|
695
|
+
isReverse() {
|
|
696
|
+
return reverse;
|
|
697
|
+
},
|
|
698
|
+
add: add2,
|
|
699
|
+
remove: remove2,
|
|
700
|
+
clear,
|
|
701
|
+
events,
|
|
702
|
+
on: emitter.on,
|
|
703
|
+
off: emitter.off,
|
|
704
|
+
once: emitter.once
|
|
705
|
+
};
|
|
706
|
+
return timeline;
|
|
707
|
+
}
|
|
708
|
+
function definePlugin(plugin) {
|
|
709
|
+
return plugin;
|
|
710
|
+
}
|
|
711
|
+
const updatePlugin = definePlugin({
|
|
712
|
+
order: 100,
|
|
713
|
+
update(tween, value, terminate) {
|
|
714
|
+
const { animatedTarget, prop, unit } = tween;
|
|
715
|
+
let val = isArray(value) ? value[0] : value;
|
|
716
|
+
if (unit) {
|
|
717
|
+
val += unit;
|
|
718
|
+
}
|
|
719
|
+
animatedTarget.target[prop] = val;
|
|
720
|
+
return terminate;
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
const initPlugin = definePlugin({
|
|
724
|
+
order: 0,
|
|
725
|
+
init(tween, terminate) {
|
|
726
|
+
if (tween.between.length === 0) {
|
|
727
|
+
const to = toArray(tween.to);
|
|
728
|
+
const from = toArray(tween.from);
|
|
729
|
+
tween.between = to.map((value, i) => ({
|
|
730
|
+
from: +from[i] || 0,
|
|
731
|
+
to: +value || 0,
|
|
732
|
+
round: tween.round
|
|
733
|
+
}));
|
|
734
|
+
return terminate;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
});
|
|
738
|
+
use(updatePlugin);
|
|
739
|
+
use(initPlugin);
|
|
740
|
+
function createAnimation(target, keyframes, options) {
|
|
741
|
+
return createTimeline(options).add(target, keyframes, options);
|
|
742
|
+
}
|
|
743
|
+
export {
|
|
744
|
+
createAnimation,
|
|
745
|
+
createTimeline,
|
|
746
|
+
easings,
|
|
747
|
+
ticker,
|
|
748
|
+
withFrom
|
|
749
|
+
};
|
package/package.json
CHANGED
|
@@ -1,19 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lwa",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "轻量级动画库",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"module": "./dist/lwa.js",
|
|
5
|
+
"main": "./dist/lwa.cjs",
|
|
6
|
+
"module": "./dist/lwa.mjs",
|
|
8
7
|
"types": "./dist/lwa.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/lwa.d.ts",
|
|
11
|
+
"node": {
|
|
12
|
+
"import": {
|
|
13
|
+
"production": "./dist/lwa.mjs",
|
|
14
|
+
"development": "./dist/lwa.mjs",
|
|
15
|
+
"default": "./dist/lwa.mjs"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"production": "./dist/lwa.cjs",
|
|
19
|
+
"development": "./dist/lwa.cjs",
|
|
20
|
+
"default": "./dist/lwa.cjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"import": "./dist/lwa.mjs",
|
|
24
|
+
"require": "./dist/lwa.cjs"
|
|
25
|
+
},
|
|
26
|
+
"./dist/*": "./dist/*",
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
9
29
|
"scripts": {
|
|
10
30
|
"dev": "vite",
|
|
11
31
|
"build:docs": "vue-tsc -b && vite build",
|
|
12
32
|
"preview": "vite preview",
|
|
13
|
-
"deploy": "node deploy.
|
|
33
|
+
"deploy": "node deploy.mjs",
|
|
14
34
|
"buildDocsAndDeploy": "npm run build:docs && npm run deploy",
|
|
15
|
-
"build:dts": "
|
|
16
|
-
"build:lib": "node build-lib.
|
|
35
|
+
"build:dts": "node build-dts.mjs",
|
|
36
|
+
"build:lib": "node build-lib.mjs && npm run build:dts"
|
|
17
37
|
},
|
|
18
38
|
"devDependencies": {
|
|
19
39
|
"@microsoft/api-extractor": "^7.47.0",
|