lwa 0.2.3-alpha → 0.3.0
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/README.md +69 -10
- package/dist/lwa.cjs +2 -2
- package/dist/lwa.full.es.js +105 -128
- package/dist/lwa.full.umd.js +2 -2
- package/dist/lwa.mjs +91 -114
- package/dist/lwa.slim.d.ts +223 -0
- package/dist/lwa.slim.es.js +712 -0
- package/dist/lwa.slim.umd.js +2 -0
- package/package.json +15 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* lwa 0.2.3 | MIT license | https://github.com/sutras/lwa */
|
|
2
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).lwa={})}(this,(function(e){"use strict";var n=Object.defineProperty,t=Math.pow,o=(e,t,o)=>((e,t,o)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o)(e,"symbol"!=typeof t?t+"":t,o);const r=new Set;let i=0,a=!0;function u(){0===r.size?a||(a=!0,cancelAnimationFrame(i)):(new Set(r).forEach((e=>e())),i=requestAnimationFrame(u))}const c={add:function(e){r.add(e),a&&(a=!1,i=requestAnimationFrame(u))},remove:function(e){r.delete(e)}},s={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 n=1.70158;return e*e*((n+1)*e-n)},Bounce:()=>e=>{const n=7.5625,t=2.75;return 1-((e=1-e)<1/t?n*e*e:e<2/t?n*(e-=1.5/t)*e+.75:e<2.5/t?n*(e-=2.25/t)*e+.9375:n*(e-=2.625/t)*e+.984375)}};["Quad","Cubic","Quart","Quint"].forEach(((e,n)=>{l[e]=()=>e=>Math.pow(e,n+2)})),Object.keys(l).forEach((e=>{const n=l[e];s["easeIn"+e]=n,s["easeOut"+e]=(e,t)=>o=>1-n(e,t)(1-o),s["easeInOut"+e]=(e,t)=>o=>o<.5?n(e,t)(2*o)/2:1-n(e,t)(2-2*o)/2}));const f=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/,d=new RegExp("^([+\\-*/%]=|)("+f.source+")("+/%|px|rpx|em|rem|vw|vh|deg|rad|turn|ex|ch|vmin|vmax|pc|pt|in|cm|mm/.source+"|)$","i"),p=new RegExp("^([<>]|)([+-]=|)("+f.source+"|)(%|)$");function m(e){return"number"==typeof e}function g(e){return"string"==typeof e}function h(e){return null!==e&&"object"==typeof e}function y(e){return"function"==typeof e}function b(e){return Array.isArray(e)}function v(e){return Array.isArray(e)?e:[e]}const w=Symbol();class x{}class E extends x{constructor(e,n){super(),o(this,"from"),o(this,"to"),this.from=e,this.to=n}}const M=[];function k(e){const n=[];return b(e)||(e=[e]),e.flat().forEach((e=>{e&&(g(e)?n.push(...Array.from(document.querySelectorAll(e))):!function(e){let n;return h(e)&&Number.isInteger(n=e.length)&&n<t(2,32)}(e)?(h(e)||y(e))&&n.push(e):n.push(...Array.from(e)))})),Array.from(new Set(n))}function A(e,n){return y(e)?e(n.target,n.index,n.total):e}function D(e,n){const{duration:t,delay:o,begin:r,easing:i,between:a}=n;return a.map((n=>function(n){const{from:a,to:u,round:c}=n;let s=e<=r+o?a:e>=r+o+t?u:a+i((e-r-o)/t)*(u-a);return c&&(s=Math.round(s*c)/c),s}(n)))}function T(e,n){return b(e=A(e,n))?e.map((e=>T(e,n)[0])):((m(e)||g(e)||e instanceof x)&&(e={value:e}),[e])}function O(e,n,t,o,r,i,a){const u=n.length;let c,l=r||0;function f(n,r,c){var f,p,m,h,b,v,x;const k=A(null!=(f=n.duration)?f:a,e),D=A(null!=(p=n.delay)?p:0===r?o.delay:0,e),T=A(null!=(m=n.endDelay)?m:r===u-1?o.endDelay:0,e),O=A(y(S=null!=(h=n.easing)?h:o.easing)?S:()=>(s[S]||s.linear)(0,0),e);var S;const j=A(null!=(b=n.round)?b:o.round,e),I=D+k+T,F=l,P=F+I;if(l+=I,!c){let e;c=(e=i[t])?e[e.length-1]:void 0}const q=n.value;let B,C;const Q=q instanceof E;Q?(C=A(q.from,e),B=A(q.to,e)):B=q,!Q&&c&&(C=c.to);let R=!1;void 0===C&&(C=e.target[t],R=!0);let z="",$="";if(g(B)){const e=d.exec(B);e&&(z=e[1],B=parseFloat(e[2])||0,$=e[3])}const N={animatedTarget:e,prop:t,duration:k,delay:D,endDelay:T,begin:F,end:P,easing:O,data:{},from:C,to:B,withoutFrom:R,round:j,unit:$,operator:z,between:[]};for(let e=0,t=M.length;e<t;e++){if((null==(x=(v=M[e]).init)?void 0:x.call(v,N,w))===w)break}return N}a=(null!=a?a:o.duration)/u;const p=n.map(((e,n)=>c=f(e,n,c))).sort(((e,n)=>e.begin-n.begin));return{endTime:l,tweens:p}}function S(e,n,t){const o={},r=A(t.duration,e)/n.length;let i=0;return n.forEach((n=>{const a=function(e,n,t,o,r,i){let a={};for(let u in n){const c=n[u];null!=c&&(a[u]=O(e,T(c,e),u,t,o,r,i))}return a}(e,n,t,i,o,r);for(let e in a)i=Math.max(i,a[e].endTime),o[e]=(o[e]||[]).concat(a[e].tweens)})),o}function j(e,n,t){return e.map((e=>{const o=S(e,n,t);return Object.keys(o).map((e=>{return{seek:function(e){var t,o;let r;for(let i,a=0;i=n[a++];){if(i.begin<=e&&i.end>=e){r=i;break}e>i.end&&(!n[a+1]||n[a+1].begin>e)&&(r=i)}if(r){let n,i=D(e,r);for(let e=M.length-1;e>=0;e--){if(n=null==(o=(t=M[e]).update)?void 0:o.call(t,r,i,w),n===w)return;void 0!==n&&(i=n)}}},getDuration:function(){return Math.max(...n.map((e=>e.end)))},tweens:n=o[e]};var n}))})).flat()}const I={duration:500,delay:0,endDelay:0,easing:"easeInOutQuad",round:0};function F(e){v(e).forEach((e=>{M.includes(e)||(M.push(e),M.sort(((e,n)=>n.order-e.order)))}))}const P="alternate-reverse",q="reverse",B="alternate";function C(e){return e===q||e===P}function Q(e){return e===B||e===P}const R={externalTicker:!1,autoplay:!0,direction:"normal",loop:1},z=["begin","loopBegin","complete","loopComplete","pause","play","update"];function $(e){const n=Object.assign({},R,e),{externalTicker:t,autoplay:o,direction:r,loop:i}=n;let a=!1,u=!0,s=0,l=0,f=i,d=C(r),y=0,v=[];const w=function(){const e={};function n(n,t){let o=e[n];o||(o=e[n]=new Set),o.add(t)}function t(n,t){if(t){const o=e[n];o&&(o.delete(t),0===o.size&&delete e[n])}else delete e[n]}return{on:n,off:t,once:function(e,o){n(e,(function n(...r){o(...r),t(e,n)}))},emit:function(n,...t){const o=e[n];o&&o.forEach((e=>{e(...t)}))}}}();function x(){return 0===f&&l===y}function E(e){let n=!1;e>=y?(e=y,n=!0):e<0&&(e=0),l=e;const t=d?y-l:l;v.forEach((({target:e,begin:n})=>{e.seek(t-n)})),w.emit("update",t,0===y?0:l/y),n&&(w.emit("loopComplete"),--f<0&&(f=0),0===f?(T(),w.emit("complete")):u||(Q(r)&&(d=!d),A()))}function M(){if(!u){let e=Date.now();E(e-s+l),s=e}}function A(){a?l=0:(a=!0,w.emit("begin")),w.emit("loopBegin"),D()}function D(){a?u&&(u=!1,x()?(Q(r)&&(d=!d),O()):(s=Date.now(),t||c.add(M),w.emit("play"))):A()}function T(){u||(u=!0,t||c.remove(M),w.emit("pause"))}function O(){T(),l=0,a=!1,f=i,d=C(r),D()}function S(e,n,t,o){if(function(e){return h(e)&&"getDuration"in e&&"seek"in e}(e)){let t=y;if(m(o=null!=n?n:">"))t=o;else{const{begin:e,end:n}=v[v.length-1]||{begin:0,end:0},r=n-e,[,i,a,u,c]=p.exec(o)||[,">","","",""];t="<"===i?e:">"===i?n:t;let s=+u;"%"===c&&(s=(i?r:y)/100*+u),t+="-="===a?-s:s}t=Math.max(0,t);const r=t+e.getDuration();v.push({target:e,position:o,begin:t,end:r}),y=Math.max(y,r)}else{(m(t)||g(t))&&(o=t,t=void 0);const r=function(e,n,t){const o=Object.assign({},I,t);return j((r=k(e)).map(((e,n)=>({target:e,index:n,total:r.length}))),b(n)?n:[n],o);var r}(e,n,t);r.forEach(((e,n)=>{S(e,0===n?o:"<")}))}return F}z.forEach((e=>{n[e]&&w.on(e,n[e])})),o&&0!==i&&A();const F={play:D,pause:T,finish:function(){x()||E(y)},restart:O,seek:E,progress:function(e){var n,t,o;E((o=1,((n=e)<(t=0)?t:n>o?o:n)*y))},tick:()=>{t&&M()},getPosition:()=>l,getDuration:()=>y,getProgress:()=>0===y?0:l/y,isReverse:()=>d,add:S,remove:function(e){const n=v.findIndex((n=>n.target===e));-1!==n&&(v.splice(n,1),function(){const e=[...v];v=[],y=0,e.forEach((e=>{S(e.target,e.position)}))}())},clear:function(){T(),y=0,v=[]},events:v,on:w.on,off:w.off,once:w.once};return F}const N={order:100,update(e,n,t){const{animatedTarget:o,prop:r,unit:i}=e;let a=b(n)?n[0]:n;return i&&(a+=i),o.target[r]=a,t}},G={order:0,init(e,n){if(0===e.between.length){const t=v(e.to),o=v(e.from);return e.between=t.map(((n,t)=>({from:+o[t]||0,to:+n||0,round:e.round}))),n}}};F(N),F(G),e.createAnimation=function(e,n,t){return $(t).add(e,n,t)},e.createTimeline=$,e.easings=s,e.ticker=c,e.withFrom=function(e,n){return new E(e,n)},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lwa",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "轻量级动画库",
|
|
5
5
|
"main": "./dist/lwa.cjs",
|
|
6
6
|
"module": "./dist/lwa.mjs",
|
|
@@ -32,21 +32,33 @@
|
|
|
32
32
|
"preview": "vite preview",
|
|
33
33
|
"deploy": "node deploy.mjs",
|
|
34
34
|
"buildDocsAndDeploy": "npm run build:docs && npm run deploy",
|
|
35
|
-
"build:dts": "
|
|
35
|
+
"build:dts": "node build-dts.mjs",
|
|
36
36
|
"build:lib": "node build-lib.mjs && npm run build:dts"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@microsoft/api-extractor": "^7.47.0",
|
|
40
|
+
"@tailwindcss/vite": "^4.1.11",
|
|
41
|
+
"@types/markdown-it": "^14.1.2",
|
|
42
|
+
"@types/markdown-it-container": "^2.0.10",
|
|
40
43
|
"@types/node": "^20.14.9",
|
|
41
44
|
"@vitejs/plugin-vue": "^5.0.5",
|
|
42
45
|
"consola": "^3.2.3",
|
|
46
|
+
"fast-glob": "^3.3.3",
|
|
43
47
|
"gh-pages": "^6.1.1",
|
|
44
48
|
"lodash-es": "^4.17.21",
|
|
49
|
+
"markdown-it": "^14.1.0",
|
|
50
|
+
"markdown-it-async": "^2.2.0",
|
|
51
|
+
"markdown-it-container": "^4.0.0",
|
|
52
|
+
"markdown-it-prism": "^3.0.0",
|
|
45
53
|
"pinia": "^2.1.7",
|
|
54
|
+
"prismjs": "^1.30.0",
|
|
55
|
+
"tailwindcss": "^4.1.11",
|
|
46
56
|
"terser": "^5.31.1",
|
|
47
57
|
"typescript": "^5.5.2",
|
|
48
58
|
"unplugin-vue-markdown": "^0.26.2",
|
|
49
59
|
"vite": "^5.3.1",
|
|
60
|
+
"vite-plugin-svg-icons": "^2.0.1",
|
|
61
|
+
"vitepress-plugin-group-icons": "^1.6.2",
|
|
50
62
|
"vue": "^3.4.29",
|
|
51
63
|
"vue-router": "^4.4.0",
|
|
52
64
|
"vue-tsc": "^2.0.21"
|
|
@@ -63,6 +75,7 @@
|
|
|
63
75
|
"keywords": [
|
|
64
76
|
"animation",
|
|
65
77
|
"animate",
|
|
78
|
+
"anime",
|
|
66
79
|
"动画"
|
|
67
80
|
]
|
|
68
81
|
}
|