Security News
Supply Chain Attack Detected in @solana/web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@lottiefiles/dotlottie-solid
Advanced tools
A Solid library for rendering lottie and dotLottie animations in the browser.
dotLottie is an open-source file format that aggregates one or more Lottie files and their associated resources into a single file. They are ZIP archives compressed with the Deflate compression method and carry the file extension of ".lottie".
npm install @lottiefiles/dotlottie-solid
import { DotLottieSolid } from '@lottiefiles/dotlottie-solid';
const App = () => {
return (
<DotLottieSolid
src="path/to/animation.lottie"
loop
autoplay
/>
);
};
🚧 WIP
The DotLottieSolidProps
extends the HTMLCanvasElement
Props and accepts all the props that the HTMLCanvasElement
accepts. In addition to that, it also accepts the following props:
Property name | Type | Required | Default | Description | |
---|---|---|---|---|---|
autoplay | boolean | false | Auto-starts the animation on load. | ||
loop | boolean | false | Determines if the animation should loop. | ||
src | string | undefined | URL to the animation data (.json or .lottie ). | ||
speed | number | 1 | Animation playback speed. 1 is regular speed. | ||
data | string | ArrayBuffer | undefined | Animation data provided either as a Lottie JSON string or as an ArrayBuffer for .lottie animations. | ||
mode | string | "forward" | Animation play mode. Accepts "forward", "reverse", "bounce", "reverse-bounce". | ||
backgroundColor | string | undefined | Background color of the canvas. Accepts 6-digit or 8-digit hex color string (e.g., "#000000", "#000000FF"), | ||
segment | [number, number] | [0, totalFrames - 1] | Animation segment. Accepts an array of two numbers, where the first number is the start frame and the second number is the end frame. | ||
renderConfig | RenderConfig | {} | Configuration for rendering the animation. | ||
playOnHover | boolean | false | Determines if the animation should play on mouse hover and pause on mouse out. | ||
dotLottieRefCallback | (v: DotLottie) => void | undefined | Callback function that receives a reference to the dotLottie web player instance. | ||
useFrameInterpolation | boolean | true | Determines if the animation should update on subframes. If set to false, the original AE frame rate will be maintained. If set to true, it will refresh at each requestAnimationFrame, including intermediate values. The default setting is true. | ||
autoResizeCanvas | boolean | true | Determines if the canvas should resize automatically to its container | ||
marker | string | undefined | The Lottie named marker to play. |
The renderConfig
object accepts the following properties:
Property name | Type | Required | Default | Description |
---|---|---|---|---|
devicePixelRatio | number | window.devicePixelRatio | 1 | The device pixel ratio. |
DotLottieSolid
component makes it easy to build custom playback controls for the animation. It exposes a dotLottieRefCallback
prop that can be used to get a reference to the dotLottie
web player instance. This instance can be used to control the playback of the animation using the methods exposed by the dotLottie
web player instance.
Here is an example:
import { createSignal } from 'solid-js';
import { DotLottieSolid } from '@lottiefiles/dotlottie-solid';
const App = () => {
const [dotLottie, setDotLottie] = createSignal();
function play() {
if (dotLottie()) {
dotLottie().play();
}
}
function pause() {
if (dotLottie()) {
dotLottie().pause();
}
}
function stop() {
if (dotLottie()) {
dotLottie().stop();
}
}
function seek() {
if (dotLottie()) {
dotLottie().setFrame(30);
}
}
return (
<DotLottieSolid
src="path/to/animation.lottie"
loop
autoplay
dotLottieRefCallback={setDotLottie}
/>
<div>
<button onClick={play}>Play</button>
<button onClick={pause}>Pause</button>
<button onClick={stop}>Stop</button>
<button onClick={seek}>Seek to frame no. 30</button>
</div>
);
};
You can find the list of methods that can be used to control the playback of the animation here.
DotLottieSolid
component can receive a dotLottieRefCallback
prop that can be used to get a reference to the dotLottie
web player instance. This reference can be used to listen to player events emitted by the dotLottie
web instance.
Here is an example:
import { createSignal, createEffect, onCleanup } from 'solid-js';
import { DotLottieSolid } from '@lottiefiles/dotlottie-solid';
const App = () => {
const [dotLottie, setDotLottie] = createEffect();
createEffect(() => {
// This function will be called when the animation starts playing.
function onPlay() {
console.log('Animation start playing');
}
// This function will be called when the animation is paused.
function onPause() {
console.log('Animation paused');
}
// This function will be called when the animation is completed.
function onComplete() {
console.log('Animation completed');
}
function onFrameChange({currentFrame}) {
console.log('Current frame: ', currentFrame);
}
// Listen to events emitted by the DotLottie instance when it is available.
if (dotLottie()) {
dotLottie().addEventListener('play', onPlay);
dotLottie().addEventListener('pause', onPause);
dotLottie().addEventListener('complete', onComplete);
dotLottie().addEventListener('frame', onFrameChange);
}
});
onCleanup(() => {
if (dotLottie()) {
dotLottie().removeEventListener('play', onPlay);
dotLottie().removeEventListener('pause', onPause);
dotLottie().removeEventListener('complete', onComplete);
dotLottie().removeEventListener('frame', onFrameChange);
}
})
return (
<DotLottieSolid
src="path/to/animation.lottie"
loop
autoplay
dotLottieRefCallback={setDotLottie}
/>
);
};
dotLottie instance exposes multiple events that can be listened to. You can find the list of events here.
pnpm install
pnpm dev
pnpm build
FAQs
Solid wrapper around the dotlottie-web library
The npm package @lottiefiles/dotlottie-solid receives a total of 1,252 weekly downloads. As such, @lottiefiles/dotlottie-solid popularity was classified as popular.
We found that @lottiefiles/dotlottie-solid demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.