@lordicon/web 1.0.0 → 1.1.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/{LICENSE → LICENSE.md} +2 -11
- package/dist/index.js +5289 -6264
- package/dist/src/index.d.ts +2 -0
- package/dist/src/interfaces.d.ts +163 -0
- package/dist/src/lottie.d.ts +48 -0
- package/dist/src/parsers.d.ts +40 -0
- package/dist/{index.d.ts → src/player.d.ts} +233 -388
- package/dist/src/utils.d.ts +39 -0
- package/examples/03-states.html +3 -1
- package/examples/04-events.ts +0 -1
- package/examples/index.html +1 -0
- package/package.json +10 -10
- package/src/player.ts +15 -1
package/examples/03-states.html
CHANGED
package/examples/04-events.ts
CHANGED
package/examples/index.html
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lordicon/web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A lightweight and flexible player for seamlessly embedding, controlling, and customizing animated Lordicon icons in any web application.",
|
|
5
5
|
"repository": "https://github.com/lordicondev/player-web",
|
|
6
6
|
"homepage": "https://lordicon.com/",
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@lordicon/internal": "^0.5.0",
|
|
27
|
-
"vite": "^
|
|
28
|
-
"vite-plugin-dts": "^
|
|
29
|
-
"concurrently": "^
|
|
30
|
-
"eslint-config-prettier": "^
|
|
31
|
-
"eslint": "^
|
|
32
|
-
"prettier": "^3.
|
|
33
|
-
"typescript": "^
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
35
|
-
"@typescript-eslint/parser": "^
|
|
27
|
+
"vite": "^8.0.16",
|
|
28
|
+
"vite-plugin-dts": "^5.0.2",
|
|
29
|
+
"concurrently": "^10.0.3",
|
|
30
|
+
"eslint-config-prettier": "^10.1.8",
|
|
31
|
+
"eslint": "^10.5.0",
|
|
32
|
+
"prettier": "^3.8.4",
|
|
33
|
+
"typescript": "^6.0.3",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^8.61.1",
|
|
35
|
+
"@typescript-eslint/parser": "^8.61.1",
|
|
36
36
|
"@types/node": "^22.13.13"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/src/player.ts
CHANGED
|
@@ -115,6 +115,7 @@ export class Player {
|
|
|
115
115
|
|
|
116
116
|
protected _state?: IconState;
|
|
117
117
|
protected _availableStates: IconState[];
|
|
118
|
+
protected _animationFrameRate: number = 0;
|
|
118
119
|
|
|
119
120
|
/**
|
|
120
121
|
* Creates a new Player instance.
|
|
@@ -133,6 +134,9 @@ export class Player {
|
|
|
133
134
|
this._iconData = data;
|
|
134
135
|
this._initialProperties = properties || {};
|
|
135
136
|
|
|
137
|
+
// Parse animation frame rate for timing calculations.
|
|
138
|
+
this._animationFrameRate = data.fr || 30;
|
|
139
|
+
|
|
136
140
|
// Parse available states from Lottie markers.
|
|
137
141
|
this._availableStates = (data.markers || []).map((c: any) => {
|
|
138
142
|
const parts: string[] = c.cm.split(':');
|
|
@@ -180,7 +184,7 @@ export class Player {
|
|
|
180
184
|
}
|
|
181
185
|
|
|
182
186
|
// Fallback to default state if initial is invalid.
|
|
183
|
-
if (this._initialProperties.state && !this._state) {
|
|
187
|
+
if (this._initialProperties.state && !this._state && this._initialProperties.state !== '*') {
|
|
184
188
|
this._state = this._availableStates.filter(c => c.default)[0];
|
|
185
189
|
}
|
|
186
190
|
}
|
|
@@ -620,6 +624,8 @@ export class Player {
|
|
|
620
624
|
|
|
621
625
|
if (isNil(state)) {
|
|
622
626
|
this._state = this._availableStates.filter(c => c.default)[0];
|
|
627
|
+
} else if (state === '*') {
|
|
628
|
+
this._state = undefined;
|
|
623
629
|
} else if (state) {
|
|
624
630
|
this._state = this._availableStates.filter(c => c.name === state)[0];
|
|
625
631
|
|
|
@@ -731,6 +737,14 @@ export class Player {
|
|
|
731
737
|
return this._availableStates;
|
|
732
738
|
}
|
|
733
739
|
|
|
740
|
+
/**
|
|
741
|
+
* Gets the frame rate of the animation.
|
|
742
|
+
* @returns Frame rate in frames per second.
|
|
743
|
+
*/
|
|
744
|
+
get frameRate() {
|
|
745
|
+
return this._animationFrameRate;
|
|
746
|
+
}
|
|
747
|
+
|
|
734
748
|
/**
|
|
735
749
|
* Returns true if the animation is currently playing.
|
|
736
750
|
*/
|