-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add typescript declarations file #17
base: master
Are you sure you want to change the base?
Add typescript declarations file #17
Conversation
Could you add more player's methods to the type declaration file. That make controlling player via script more comfortable. |
I have just researched import type { SvelteComponentTyped } from 'svelte'
export class LottiePlayer extends SvelteComponentTyped<{
autoplay?: boolean
background: string
controls: boolean
controlsLayout?: string[]
count?: number
defaultFrame?: number
direction?: number
height: number
hover?: boolean
loop?: boolean
mode?: 'normal' | 'bounce'
onToggleZoom?: (isZoomed: boolean) => void
renderer?: 'svg' | 'canvas'
speed?: number
src?: string
style?: string
width: number
}> {
/**
* Returns the lottie-web version and this player's version
*/
getVersions(): { lottieWebVersion: string, svelteLottiePlayerVersion: string };
/**
* Returns the lottie-web instance used in the component.
*/
getLottie(): any;
/**
* Pause animation play.
*/
pause(): void;
/**
* Start playing animation.
*/
play(): void;
/**
* Stops animation play.
*/
stop(): void;
/**
* Freeze animation play.
* This internal state pauses animation and is used to differentiate between
* user requested pauses and component instigated pauses.
*/
freeze(): void;
/**
* Resize animation.
*/
resize(): void;
/**
* Seek to a given frame.
* @param frame Frame number or Percent string to seek to.
*/
seek(frame: number|string): void;
/**
* Snapshot the current frame as SVG.
* @param download If 'download' argument is boolean true, then a download is triggered in browser.
*/
snapshot(download?: boolean): void;
/**
* Sets the looping of the animation.
* @param value Whether to enable looping. Boolean true enables looping.
*/
setLooping(value: boolean): void;
/**
* Sets the speed of the animation.
* @param value The speed of the animation. 1 is normal speed.
*/
setSpeed(value: number): void;
/**
* Animation play direction.
* @param value Direction values.
*/
setDirection(value: number): void;
/**
* Toggle playing state.
*/
togglePlay(): void;
/**
* Toggle zoom state.
*/
toggleZoom(): void;
/**
* Toggles animation looping.
*/
toggleLooping(): void;
/**
* Sets background color.
*/
setBackgroundColor(color: string): void;
} |
@megaheart Thanks for the suggestion and input. 🙏 I pretty much used your code except for |
@jneuendorf I think your // package.json
{
...
+ "types": "index.d.ts"
...
} |
@jakemckown Thanks for the hint. Do you have a preference regarding the location of the file? As it seems both the |
@jneuendorf I think where you have it in the root is the best option for adding a declarations file to a non-TypeScript project. It technically doesn't matter as long as the // package.json
{
...
"files": [
"src/components",
- "dist"
+ "dist",
+ "index.d.ts"
]
...
} |
|
Hey, what's the hold up on this pull request? |
Can this be merge or is there anything missing I can help with? For now, I've copy pasted the contents in |
Closes #16.
Please double check, if the types are correct and complete 😅