mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
web: code refactoring
improved code consistency: - removed double-quotes on string literal. - removed double-equals (==) - updated comments
This commit is contained in:
parent
a9b6907e41
commit
d8891187cd
1 changed files with 26 additions and 24 deletions
|
@ -60,38 +60,38 @@ export enum MimeType {
|
||||||
|
|
||||||
// Define valid player states
|
// Define valid player states
|
||||||
export enum PlayerState {
|
export enum PlayerState {
|
||||||
Destroyed = "destroyed", // Player is destroyed by `destroy()` method
|
Destroyed = 'destroyed', // Player is destroyed by `destroy()` method
|
||||||
Error = "error", // An error occurred
|
Error = 'error', // An error occurred
|
||||||
Loading = "loading", // Player is loading
|
Loading = 'loading', // Player is loading
|
||||||
Paused = "paused", // Player is paused
|
Paused = 'paused', // Player is paused
|
||||||
Playing = "playing", // Player is playing
|
Playing = 'playing', // Player is playing
|
||||||
Stopped = "stopped", // Player is stopped
|
Stopped = 'stopped', // Player is stopped
|
||||||
Frozen = "frozen", // Player is paused due to player being invisible
|
Frozen = 'frozen', // Player is paused due to player being invisible
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define play modes
|
// Define play modes
|
||||||
export enum PlayMode {
|
export enum PlayMode {
|
||||||
Bounce = "bounce",
|
Bounce = 'bounce',
|
||||||
Normal = "normal",
|
Normal = 'normal',
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define player events
|
// Define player events
|
||||||
export enum PlayerEvent {
|
export enum PlayerEvent {
|
||||||
Complete = "complete",
|
Complete = 'complete',
|
||||||
Destroyed = "destroyed",
|
Destroyed = 'destroyed',
|
||||||
Error = "error",
|
Error = 'error',
|
||||||
Frame = "frame",
|
Frame = 'frame',
|
||||||
Freeze = "freeze",
|
Freeze = 'freeze',
|
||||||
Load = "load",
|
Load = 'load',
|
||||||
Loop = "loop",
|
Loop = 'loop',
|
||||||
Pause = "pause",
|
Pause = 'pause',
|
||||||
Play = "play",
|
Play = 'play',
|
||||||
Ready = "ready",
|
Ready = 'ready',
|
||||||
Stop = "stop",
|
Stop = 'stop',
|
||||||
}
|
}
|
||||||
|
|
||||||
const _parseLottieFromURL = async (url: string): Promise<LottieJson> => {
|
const _parseLottieFromURL = async (url: string): Promise<LottieJson> => {
|
||||||
if (typeof url !== "string") {
|
if (typeof url !== 'string') {
|
||||||
throw new Error(`The url value must be a string`);
|
throw new Error(`The url value must be a string`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ const _observerCallback = (entries: IntersectionObserverEntry[]) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const _downloadFile = (fileName: string, blob: Blob) => {
|
const _downloadFile = (fileName: string, blob: Blob) => {
|
||||||
const link = document.createElement("a");
|
const link = document.createElement('a');
|
||||||
link.setAttribute('href', URL.createObjectURL(blob));
|
link.setAttribute('href', URL.createObjectURL(blob));
|
||||||
link.setAttribute('download', fileName);
|
link.setAttribute('download', fileName);
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
|
@ -179,7 +179,7 @@ const _downloadFile = (fileName: string, blob: Blob) => {
|
||||||
@customElement('lottie-player')
|
@customElement('lottie-player')
|
||||||
export class LottiePlayer extends LitElement {
|
export class LottiePlayer extends LitElement {
|
||||||
/**
|
/**
|
||||||
* LottieFiles JSON data or URL to JSON.
|
* Lottie animation JSON data or URL to JSON.
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
@property({ type: String })
|
@property({ type: String })
|
||||||
|
@ -431,6 +431,8 @@ export class LottiePlayer extends LitElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure and load
|
* Configure and load
|
||||||
|
* @param src Lottie animation JSON data or URL to JSON.
|
||||||
|
* @param mimeType The MIME type of the data to be loaded, defaults to JSON
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
public async load(src: string | object, mimeType: MimeType = MimeType.JSON): Promise<void> {
|
public async load(src: string | object, mimeType: MimeType = MimeType.JSON): Promise<void> {
|
||||||
|
@ -461,7 +463,7 @@ export class LottiePlayer extends LitElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
this._beginTime = Date.now() / 1000;
|
this._beginTime = Date.now() / 1000;
|
||||||
if (this.currentState == PlayerState.Playing) {
|
if (this.currentState === PlayerState.Playing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue