https://github.com/reslear/dotlottie-player-core
dotLottie player core
https://github.com/reslear/dotlottie-player-core
Last synced: 4 months ago
JSON representation
dotLottie player core
- Host: GitHub
- URL: https://github.com/reslear/dotlottie-player-core
- Owner: reslear
- License: mit
- Created: 2022-10-14T12:58:03.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-25T13:58:41.000Z (about 2 years ago)
- Last Synced: 2024-04-28T01:29:22.352Z (about 2 years ago)
- Language: TypeScript
- Homepage: dotlottie-player-core-playground.vercel.app
- Size: 210 KB
- Stars: 2
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# dotLottie-player-core
Only fetching and parse functions.
[](https://www.npmjs.com/package/@reslear/dotlottie-player-core)
[](https://www.npmjs.com/package/@reslear/dotlottie-player-core)


[](https://packagephobia.com/result?p=@reslear/dotlottie-player-core)
[](https://github.com/semantic-release/semantic-release)

🕹 [**Live Playground**](https://dotlottie-player-core-playground.vercel.app)
## Features
- 🏎 High performance (using [`fflate`](https://github.com/101arrowz/fflate))
- ⚙️ [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) based
- 📦 **CJS** and **ESM** support
- 💪 fylly typed with **TypeScript**
- 🏋️♀️ Lightweight with **~13kb** size
## Install
```bash
pnpm add @reslear/dotlottie-player-core
```
## Usage
### fetchLottie
fetch method for get animation and parse to lottie json.
```ts
import { fetchLottie } from '@reslear/dotlottie-player-core'
const lottieJson = await fetchLottie('/my-animation.lottie')
// {"v":"5.6.8","fr":24,"ip":0,"op":144,"w":2161,"h"...}
```
#### Arguments:
1. **`url`** - path to `.lottie`, `.json` animation file
also support [base64 data URI](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)
```ts
fetchLottie('data:application/json;base64,')
```
2. **`fetchOptions`** - Fetch API [options](https://developer.mozilla.org/en-US/docs/Web/API/fetch#options)
```ts
fetchLottie(url, {
mode: 'no-cors',
})
```
## Inspired
- [dotlottie-player](https://github.com/dotlottie/player-component/blob/master/src/dotlottie-player.ts)
## License
MIT by [@reslear](github.com/reslear)