@lordicon/web 1.0.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/.prettierrc +6 -0
- package/LICENSE +30 -0
- package/README.md +148 -0
- package/dist/index.d.ts +388 -0
- package/dist/index.js +6279 -0
- package/examples/01-play.html +16 -0
- package/examples/01-play.ts +13 -0
- package/examples/02-customization.html +26 -0
- package/examples/02-customization.ts +49 -0
- package/examples/03-states.html +21 -0
- package/examples/03-states.ts +31 -0
- package/examples/04-events.html +18 -0
- package/examples/04-events.ts +36 -0
- package/examples/05-playback-control.html +25 -0
- package/examples/05-playback-control.ts +60 -0
- package/examples/icons/coins.json +1 -0
- package/examples/icons/lock.json +1 -0
- package/examples/index.html +59 -0
- package/examples/main.css +45 -0
- package/examples/utils.ts +9 -0
- package/package.json +38 -0
- package/src/index.ts +2 -0
- package/src/interfaces.ts +181 -0
- package/src/lottie.ts +203 -0
- package/src/parsers.ts +230 -0
- package/src/player.ts +807 -0
- package/src/utils.ts +100 -0
- package/tsconfig.json +25 -0
- package/vite-examples.config.ts +14 -0
- package/vite.config.ts +25 -0
package/.prettierrc
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Lordicon
|
|
4
|
+
|
|
5
|
+
====
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
|
24
|
+
|
|
25
|
+
====
|
|
26
|
+
|
|
27
|
+
Files located in the node_modules directories are externally
|
|
28
|
+
maintained libraries used by this software which have their own
|
|
29
|
+
licenses; we recommend you read them, as their terms may differ from the
|
|
30
|
+
terms above.
|
package/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Lordicon Web Player
|
|
2
|
+
|
|
3
|
+
A lightweight and flexible player for seamlessly embedding, controlling, and customizing animated [Lordicon](https://lordicon.com/) icons in any web application.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ✨ Simple API for controlling Lottie-based icon animations
|
|
8
|
+
- 📦 Supports Lordicon icon files
|
|
9
|
+
- 🎨 Easy customization of colors, stroke, and animation state
|
|
10
|
+
- 🔔 Event system for reacting to animation lifecycle
|
|
11
|
+
- 🛡️ TypeScript support
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install @lordicon/web
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
> **Note:**
|
|
22
|
+
> This repository contains an `examples` directory with a rich collection of usage examples and integration scenarios.
|
|
23
|
+
> Feel free to explore it for more advanced use cases and inspiration!
|
|
24
|
+
|
|
25
|
+
### Basic Example
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import { Player } from '@lordicon/web';
|
|
29
|
+
|
|
30
|
+
const container = document.getElementById('icon');
|
|
31
|
+
const data = /* Lottie JSON data */;
|
|
32
|
+
|
|
33
|
+
const player = new Player(container, data, {
|
|
34
|
+
colors: {
|
|
35
|
+
primary: '#ff0000',
|
|
36
|
+
secondary: '#0000ff',
|
|
37
|
+
},
|
|
38
|
+
stroke: 2,
|
|
39
|
+
state: 'in-reveal',
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
player.play();
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Customizing Properties
|
|
46
|
+
|
|
47
|
+
You can update properties at any time:
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
player.colors.primary = '#00ff00';
|
|
51
|
+
player.stroke = 3;
|
|
52
|
+
player.state = 'hover-jump';
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Or set multiple at once (all unspecified properties will be reset to their default values):
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
player.properties = {
|
|
59
|
+
colors: { primary: '#123456' },
|
|
60
|
+
stroke: 1,
|
|
61
|
+
state: 'hover-jump',
|
|
62
|
+
};
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Events
|
|
66
|
+
|
|
67
|
+
Register event listeners:
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
player.addEventListener('complete', () => {
|
|
71
|
+
console.log('Animation completed!');
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Supported events:
|
|
76
|
+
|
|
77
|
+
- `ready` – Fired when the player is initialized and ready to use.
|
|
78
|
+
- `complete` – Fired when the animation finishes playing.
|
|
79
|
+
- `frame` – Fired on each frame update.
|
|
80
|
+
- `refresh` – Fired when the player is refreshed, for example, after icon customization.
|
|
81
|
+
|
|
82
|
+
## API
|
|
83
|
+
|
|
84
|
+
Player
|
|
85
|
+
|
|
86
|
+
__Constructor__
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
new Player(container, data, properties, options)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
- `container` - The DOM element where the player will be rendered.
|
|
93
|
+
- `data` - The animation data in Lottie JSON format. You can download it from [Lordicon](https://lordicon.com/).
|
|
94
|
+
- `properties` - *(Optional)* Initial icon properties such as colors, stroke width, animation state, etc.
|
|
95
|
+
|
|
96
|
+
Example:
|
|
97
|
+
```js
|
|
98
|
+
{
|
|
99
|
+
colors: { primary: '#ff0000' },
|
|
100
|
+
stroke: 2,
|
|
101
|
+
state: 'in-reveal'
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
- `options` - *(Optional)* Additional options. By default, the player is automatically initialized and ready to use immediately.
|
|
105
|
+
|
|
106
|
+
Example:
|
|
107
|
+
```js
|
|
108
|
+
{
|
|
109
|
+
autoInit: true
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
__Methods__
|
|
114
|
+
|
|
115
|
+
- `init()`: Initialize the player (called automatically by default).
|
|
116
|
+
- `destroy()`: Destroy the player and release resources.
|
|
117
|
+
- `play()`: Play animation.
|
|
118
|
+
- `playFromStart()`: Play from the beginning of the current state.
|
|
119
|
+
- `pause()`: Pause animation.
|
|
120
|
+
- `stop()`: Stop animation.
|
|
121
|
+
- `seek(frame)`: Go to specific frame.
|
|
122
|
+
- `seekToStart()`: Move to the first frame and stop.
|
|
123
|
+
- `seekToEnd()`: Move to the last frame and stop.
|
|
124
|
+
- `switchSegment(segment)`: Sets the animation segment to play.
|
|
125
|
+
|
|
126
|
+
__Properties__
|
|
127
|
+
|
|
128
|
+
- `colors`: Proxy for color manipulation (e.g., player.colors.primary = '#fff').
|
|
129
|
+
- `stroke`: Stroke width (number or preset).
|
|
130
|
+
- `state`: Current animation state (string).
|
|
131
|
+
- `speed`: Playback speed.
|
|
132
|
+
- `direction`: Playback direction (1 or -1).
|
|
133
|
+
- `loop`: Looping (boolean).
|
|
134
|
+
- `frame`: Current frame (number).
|
|
135
|
+
- `playing`: Whether animation is playing (boolean).
|
|
136
|
+
- `ready`: Whether player is ready (boolean).
|
|
137
|
+
- `availableStates`: List of available states.
|
|
138
|
+
- `frameCount`: Total number of frames in the animation (number).
|
|
139
|
+
- `duration`: Duration of the animation in seconds (number).
|
|
140
|
+
- `properties`: Get or set multiple properties at once. Setter: Any property not provided will be reset to its default value (overwrites all properties). Getter: Returns the current properties object.
|
|
141
|
+
- `segment`: Gets the current segment of the animation as [start, end] frame numbers.
|
|
142
|
+
- `lottieInstance`: Access to the underlying internal Lottie player instance.
|
|
143
|
+
- `lottieProperties`: Array of customizable properties for the icon.
|
|
144
|
+
|
|
145
|
+
__Events__
|
|
146
|
+
|
|
147
|
+
- `addEventListener(name, handler)`: Register event handler. Supported event names: `'ready'`, `'complete'`, `'frame'`, `'refresh'`.
|
|
148
|
+
- `removeEventListener(name, handler?)`: Remove event handler(s).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object storing multiple named colors.
|
|
3
|
+
*
|
|
4
|
+
* Example:
|
|
5
|
+
* {
|
|
6
|
+
* primary: 'red',
|
|
7
|
+
* secondary: '#ff0000',
|
|
8
|
+
* }
|
|
9
|
+
*/
|
|
10
|
+
export declare interface ColorMap {
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Player event callback type.
|
|
16
|
+
*/
|
|
17
|
+
export declare type EventHandler = () => void;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Supported player event names.
|
|
21
|
+
*/
|
|
22
|
+
export declare type EventName = 'ready' | 'complete' | 'frame' | 'refresh';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Animation segment as a tuple: [startFrame, endFrame].
|
|
26
|
+
*/
|
|
27
|
+
declare type FrameSegment = [number, number];
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Properties for customizing icons.
|
|
31
|
+
*
|
|
32
|
+
* Example:
|
|
33
|
+
* {
|
|
34
|
+
* stroke: 'bold',
|
|
35
|
+
* colors: {
|
|
36
|
+
* primary: 'red',
|
|
37
|
+
* },
|
|
38
|
+
* }
|
|
39
|
+
*/
|
|
40
|
+
export declare interface IconProperties {
|
|
41
|
+
/**
|
|
42
|
+
* State (motion type) of the icon. States allow switching between multiple animations built into a single icon file.
|
|
43
|
+
*/
|
|
44
|
+
state?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Colors.
|
|
47
|
+
*/
|
|
48
|
+
colors?: ColorMap;
|
|
49
|
+
/**
|
|
50
|
+
* Stroke.
|
|
51
|
+
*/
|
|
52
|
+
stroke?: Stroke;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Details of a single animation state.
|
|
57
|
+
*/
|
|
58
|
+
export declare interface IconState {
|
|
59
|
+
name: string;
|
|
60
|
+
time: number;
|
|
61
|
+
duration: number;
|
|
62
|
+
params: string[];
|
|
63
|
+
default?: boolean;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Properties for legacy icons.
|
|
68
|
+
*/
|
|
69
|
+
export declare interface LegacyIconProperties {
|
|
70
|
+
/**
|
|
71
|
+
* Scale for legacy icons.
|
|
72
|
+
*/
|
|
73
|
+
scale?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Axis x for legacy icons.
|
|
76
|
+
*/
|
|
77
|
+
axisX?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Axis y for legacy icons.
|
|
80
|
+
*/
|
|
81
|
+
axisY?: number;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Represents a single Lottie animation instance from `@lordicon/internal`.
|
|
86
|
+
* Contains the current state and methods for controlling playback.
|
|
87
|
+
*/
|
|
88
|
+
declare type LottieAnimationInstance = {
|
|
89
|
+
name: string;
|
|
90
|
+
isLoaded: boolean;
|
|
91
|
+
currentFrame: number;
|
|
92
|
+
currentRawFrame: number;
|
|
93
|
+
firstFrame: number;
|
|
94
|
+
totalFrames: number;
|
|
95
|
+
frameRate: number;
|
|
96
|
+
frameMult: number;
|
|
97
|
+
playSpeed: number;
|
|
98
|
+
playDirection: number;
|
|
99
|
+
playCount: number;
|
|
100
|
+
isPaused: boolean;
|
|
101
|
+
autoplay: boolean;
|
|
102
|
+
loop: boolean | number;
|
|
103
|
+
renderer: any;
|
|
104
|
+
animationID: string;
|
|
105
|
+
assetsPath: string;
|
|
106
|
+
timeCompleted: number;
|
|
107
|
+
segmentPos: number;
|
|
108
|
+
isSubframeEnabled: boolean;
|
|
109
|
+
segments: FrameSegment | FrameSegment[];
|
|
110
|
+
play(name?: string): void;
|
|
111
|
+
stop(name?: string): void;
|
|
112
|
+
togglePause(name?: string): void;
|
|
113
|
+
destroy(name?: string): void;
|
|
114
|
+
pause(name?: string): void;
|
|
115
|
+
goToAndStop(value: number | string, isFrame?: boolean, name?: string): void;
|
|
116
|
+
goToAndPlay(value: number | string, isFrame?: boolean, name?: string): void;
|
|
117
|
+
includeLayers(data: any): void;
|
|
118
|
+
setSegment(init: number, end: number): void;
|
|
119
|
+
resetSegments(forceFlag: boolean): void;
|
|
120
|
+
hide(): void;
|
|
121
|
+
show(): void;
|
|
122
|
+
resize(): void;
|
|
123
|
+
setSpeed(speed: number): void;
|
|
124
|
+
setDirection(direction: PlaybackDirection_2): void;
|
|
125
|
+
setLoop(isLooping: boolean): void;
|
|
126
|
+
playSegments(segments: FrameSegment | FrameSegment[], forceFlag?: boolean): void;
|
|
127
|
+
setSubframe(useSubFrames: boolean): void;
|
|
128
|
+
getDuration(inFrames?: boolean): number;
|
|
129
|
+
triggerEvent(name: string, args: any): void;
|
|
130
|
+
addEventListener(name: string, callback: any): () => void;
|
|
131
|
+
removeEventListener(name: string, callback?: any): void;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Icon animation data in Lottie JSON format.
|
|
136
|
+
* This player is optimized for icons from [Lordicon](https://lordicon.com/).
|
|
137
|
+
*/
|
|
138
|
+
declare type LottieData = any;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Describes a property found in the animation.
|
|
142
|
+
*/
|
|
143
|
+
declare interface LottieProperty {
|
|
144
|
+
name: string;
|
|
145
|
+
path: string;
|
|
146
|
+
type: LottiePropertyType;
|
|
147
|
+
value: any;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Supported property types for Lottie animations.
|
|
152
|
+
*/
|
|
153
|
+
declare type LottiePropertyType = 'color' | 'slider' | 'point' | 'checkbox' | 'feature';
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Animation playback direction: 1 (forward) or -1 (backward).
|
|
157
|
+
*/
|
|
158
|
+
declare type PlaybackDirection_2 = 1 | -1;
|
|
159
|
+
export { PlaybackDirection_2 as PlaybackDirection }
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Player class for controlling and customizing Lottie-based icons.
|
|
163
|
+
*/
|
|
164
|
+
export declare class Player {
|
|
165
|
+
protected _container: HTMLElement;
|
|
166
|
+
protected _iconData: any;
|
|
167
|
+
protected _initialProperties: IconProperties & LegacyIconProperties;
|
|
168
|
+
protected _lottieInstance?: LottieAnimationInstance;
|
|
169
|
+
protected _ready: boolean;
|
|
170
|
+
protected _colorsProxy?: any;
|
|
171
|
+
protected _direction: PlaybackDirection_2;
|
|
172
|
+
protected _speed: number;
|
|
173
|
+
protected _lottieProperties?: LottieProperty[];
|
|
174
|
+
protected _eventHandlers: any;
|
|
175
|
+
protected _state?: IconState;
|
|
176
|
+
protected _availableStates: IconState[];
|
|
177
|
+
/**
|
|
178
|
+
* Creates a new Player instance.
|
|
179
|
+
* @param container The DOM element where the animation will be rendered.
|
|
180
|
+
* @param data Lottie animation data.
|
|
181
|
+
* @param properties Initial icon properties (colors, stroke, state, etc.).
|
|
182
|
+
* @param options Additional options (e.g., autoInit).
|
|
183
|
+
*/
|
|
184
|
+
constructor(container: HTMLElement, data: LottieData, properties?: IconProperties & LegacyIconProperties, options?: {
|
|
185
|
+
autoInit?: boolean;
|
|
186
|
+
});
|
|
187
|
+
/**
|
|
188
|
+
* Initializes the player and connects it to the DOM element.
|
|
189
|
+
* Throws an error if already initialized.
|
|
190
|
+
*/
|
|
191
|
+
init(): void;
|
|
192
|
+
/**
|
|
193
|
+
* Destroys the player and releases all resources.
|
|
194
|
+
* Throws an error if not initialized.
|
|
195
|
+
*/
|
|
196
|
+
destroy(): void;
|
|
197
|
+
/**
|
|
198
|
+
* Registers an event listener for a player event.
|
|
199
|
+
* @param name Event name (e.g., 'complete', 'frame', 'ready').
|
|
200
|
+
* @param handler Handler function to call when the event is triggered.
|
|
201
|
+
* @returns Function to remove the listener.
|
|
202
|
+
*/
|
|
203
|
+
addEventListener(name: EventName, handler: EventHandler): () => void;
|
|
204
|
+
/**
|
|
205
|
+
* Removes an event listener for a player event.
|
|
206
|
+
* @param name Event name.
|
|
207
|
+
* @param handler Handler function to remove. If not provided, removes all handlers for the event.
|
|
208
|
+
*/
|
|
209
|
+
removeEventListener(name: EventName, handler?: EventHandler): void;
|
|
210
|
+
/**
|
|
211
|
+
* Triggers a player event and invokes all registered callbacks.
|
|
212
|
+
* @param name Event name.
|
|
213
|
+
* @param args Optional arguments to pass to the callbacks.
|
|
214
|
+
*/
|
|
215
|
+
protected triggerEvent(name: EventName, args?: any): void;
|
|
216
|
+
/**
|
|
217
|
+
* Forces a re-render of the animation.
|
|
218
|
+
*/
|
|
219
|
+
protected refresh(): void;
|
|
220
|
+
/**
|
|
221
|
+
* Starts playing the animation from the current frame.
|
|
222
|
+
* Note: If the animation is finished, it cannot be played again from the last frame.
|
|
223
|
+
*/
|
|
224
|
+
play(): void;
|
|
225
|
+
/**
|
|
226
|
+
* Plays the animation from the beginning of the current state or from the start if no state is set.
|
|
227
|
+
*/
|
|
228
|
+
playFromStart(): void;
|
|
229
|
+
/**
|
|
230
|
+
* Pauses the animation at the current frame.
|
|
231
|
+
*/
|
|
232
|
+
pause(): void;
|
|
233
|
+
/**
|
|
234
|
+
* Stop the animation.
|
|
235
|
+
*/
|
|
236
|
+
stop(): void;
|
|
237
|
+
/**
|
|
238
|
+
* Moves the animation to a specific frame and stops.
|
|
239
|
+
* @param frame Frame number to seek to.
|
|
240
|
+
*/
|
|
241
|
+
seek(frame: number): void;
|
|
242
|
+
/**
|
|
243
|
+
* Moves the animation to the first frame and stops.
|
|
244
|
+
*/
|
|
245
|
+
seekToStart(): void;
|
|
246
|
+
/**
|
|
247
|
+
* Moves the animation to the last frame and stops.
|
|
248
|
+
*/
|
|
249
|
+
seekToEnd(): void;
|
|
250
|
+
/**
|
|
251
|
+
* Sets the animation segment to play.
|
|
252
|
+
* If no segment is provided, resets to the default segment.
|
|
253
|
+
* @param segment Optional segment as [start, end] frame numbers.
|
|
254
|
+
*/
|
|
255
|
+
switchSegment(segment?: [number, number]): void;
|
|
256
|
+
/**
|
|
257
|
+
* Sets multiple icon properties at once.
|
|
258
|
+
* Any property not provided will be reset to its default value.
|
|
259
|
+
* @param properties Properties to assign.
|
|
260
|
+
*/
|
|
261
|
+
set properties(properties: IconProperties);
|
|
262
|
+
/**
|
|
263
|
+
* Gets the current icon properties (colors, stroke, state).
|
|
264
|
+
* @returns The current properties.
|
|
265
|
+
*/
|
|
266
|
+
get properties(): IconProperties;
|
|
267
|
+
/**
|
|
268
|
+
* Sets all customizable colors at once.
|
|
269
|
+
* Pass null to reset all colors to default.
|
|
270
|
+
* @param colors Color map or null.
|
|
271
|
+
*/
|
|
272
|
+
set colors(colors: ColorMap | null);
|
|
273
|
+
/**
|
|
274
|
+
* Provides a proxy for reading or updating individual colors by name.
|
|
275
|
+
*
|
|
276
|
+
* Example:
|
|
277
|
+
* player.colors.primary = '#ff0000';
|
|
278
|
+
* delete player.colors.secondary;
|
|
279
|
+
*/
|
|
280
|
+
get colors(): ColorMap;
|
|
281
|
+
/**
|
|
282
|
+
* Sets the stroke width for the icon.
|
|
283
|
+
* Pass null to reset to default.
|
|
284
|
+
* @param stroke Stroke value or null.
|
|
285
|
+
*/
|
|
286
|
+
set stroke(stroke: Stroke | null);
|
|
287
|
+
/**
|
|
288
|
+
* Gets the current stroke width of the icon.
|
|
289
|
+
* @returns Stroke value or null if not set.
|
|
290
|
+
*/
|
|
291
|
+
get stroke(): Stroke | null;
|
|
292
|
+
/**
|
|
293
|
+
* Sets the current state (animation segment) of the icon.
|
|
294
|
+
* If the state does not exist, falls back to the default state.
|
|
295
|
+
* @param state State name or null for default.
|
|
296
|
+
*/
|
|
297
|
+
set state(state: string | null);
|
|
298
|
+
/**
|
|
299
|
+
* Gets the current state (animation segment) of the icon.
|
|
300
|
+
* @returns State name or null if not set.
|
|
301
|
+
*/
|
|
302
|
+
get state(): string | null;
|
|
303
|
+
/**
|
|
304
|
+
* Sets the playback speed of the animation.
|
|
305
|
+
* @param speed Playback speed (1 = normal).
|
|
306
|
+
*/
|
|
307
|
+
set speed(speed: number);
|
|
308
|
+
/**
|
|
309
|
+
* Gets the current playback speed.
|
|
310
|
+
* @returns Playback speed.
|
|
311
|
+
*/
|
|
312
|
+
get speed(): number;
|
|
313
|
+
/**
|
|
314
|
+
* Sets the playback direction.
|
|
315
|
+
* @param direction 1 for forward, -1 for reverse.
|
|
316
|
+
*/
|
|
317
|
+
set direction(direction: PlaybackDirection_2);
|
|
318
|
+
/**
|
|
319
|
+
* Gets the current playback direction.
|
|
320
|
+
* @returns Playback direction.
|
|
321
|
+
*/
|
|
322
|
+
get direction(): PlaybackDirection_2;
|
|
323
|
+
/**
|
|
324
|
+
* Enables or disables looping of the animation.
|
|
325
|
+
* @param loop True to loop, false otherwise.
|
|
326
|
+
*/
|
|
327
|
+
set loop(loop: boolean);
|
|
328
|
+
/**
|
|
329
|
+
* Gets whether the animation is set to loop.
|
|
330
|
+
* @returns True if looping, false otherwise.
|
|
331
|
+
*/
|
|
332
|
+
get loop(): boolean;
|
|
333
|
+
/**
|
|
334
|
+
* Sets the current frame of the animation.
|
|
335
|
+
* @param frame Frame number.
|
|
336
|
+
*/
|
|
337
|
+
set frame(frame: number);
|
|
338
|
+
/**
|
|
339
|
+
* Gets the current frame of the animation.
|
|
340
|
+
* @returns Current frame number.
|
|
341
|
+
*/
|
|
342
|
+
get frame(): number;
|
|
343
|
+
/**
|
|
344
|
+
* Gets the list of available states for the icon.
|
|
345
|
+
* @returns Array of available states.
|
|
346
|
+
*/
|
|
347
|
+
get availableStates(): IconState[];
|
|
348
|
+
/**
|
|
349
|
+
* Returns true if the animation is currently playing.
|
|
350
|
+
*/
|
|
351
|
+
get playing(): boolean;
|
|
352
|
+
/**
|
|
353
|
+
* Returns true if the player is ready for interaction.
|
|
354
|
+
*/
|
|
355
|
+
get ready(): boolean;
|
|
356
|
+
/**
|
|
357
|
+
* Gets the total number of frames in the animation.
|
|
358
|
+
* @returns Frame count.
|
|
359
|
+
*/
|
|
360
|
+
get frameCount(): number;
|
|
361
|
+
/**
|
|
362
|
+
* Gets the current segment of the animation as [start, end] frame numbers.
|
|
363
|
+
* @returns Segment as [start, end].
|
|
364
|
+
*/
|
|
365
|
+
get segment(): [number, number];
|
|
366
|
+
/**
|
|
367
|
+
* Gets the duration of the animation in seconds.
|
|
368
|
+
* @returns Duration in seconds.
|
|
369
|
+
*/
|
|
370
|
+
get duration(): number;
|
|
371
|
+
/**
|
|
372
|
+
* Provides access to the underlying Lottie player instance.
|
|
373
|
+
* @returns LottieAnimationInstance.
|
|
374
|
+
*/
|
|
375
|
+
get lottieInstance(): LottieAnimationInstance | undefined;
|
|
376
|
+
/**
|
|
377
|
+
* Gets all customizable properties for the icon.
|
|
378
|
+
* @returns Array of LottieProperty.
|
|
379
|
+
*/
|
|
380
|
+
get lottieProperties(): LottieProperty[];
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Supported stroke weights for icons.
|
|
385
|
+
*/
|
|
386
|
+
export declare type Stroke = 1 | 2 | 3 | 'light' | 'regular' | 'bold';
|
|
387
|
+
|
|
388
|
+
export { }
|