Lottie interactive is custom web element adding multiple types of interactivity to Lottie animations.
Lottie-interactive is available through npm.
npm install lottie-interactive
Lottie-interactive is also available though unpkg.
<script type="text/javascript" src="https://unpkg.com/lottie-interactive@latest/dist/lottie-interactive.js"></script>
From javascript module:
import { LottieInteractive } from "lottie-interactive";
Usage in markup:
<lottie-interactive path="button.json" interaction="click"></lottie-interactive>
npm i lottie-interactive
- Create a plugin for lottie-interactive in
/plugins/lottie-interactive.client.js
:
import Vue from "vue";
import LottieInteractive from "lottie-interactive";
Vue.use(LottieInteractive);
You can then use lottie-interactive inside of your templates:
<template>
<lottie-interactive
path="/animations/svgenius-logo.json"
autoplay
loop
view-box="0 0 500 300"
/>
</template>
Remarks: Animation files (.json) can be accessed if put inside the /static
directory. URLs to the animation
can also be used.
npm i lottie-interactive
Then inside of your pages:
import React from "react";
export default function Home() {
React.useEffect(() => {
import("lottie-interactive/dist/lottie-interactive.js");
});
return (
<div>
<lottie-interactive
path="/animations/svgenius-logo.json"
autoplay
loop
/>
</div>
);
}
Remarks: Animation files (.json) can be accessed if put inside the /public/
directory. URLs to the animation
can also be used.
npm i
npm start
Plays animation when user clicks on animation container
<lottie-interactive path="button.json" interaction="click"></lottie-interactive>
Freezes animation when user clicks on animation container
<lottie-interactive path="button.json" interaction="freeze-click" autoplay loop></lottie-interactive>
Plays animation when user hovers on animation container
<lottie-interactive path="button.json" interaction="hover"></lottie-interactive>
Plays animation when user hovers on animation container, plays in reverse on 'mouseexit' event
<lottie-interactive path="button.json" interaction="morph"></lottie-interactive>
Plays animation when user hovers on animation container. Locks animation at the end if user clicks. Plays in reverse on 'mouseexit' event.
<lottie-interactive path="button.json" interaction="morph-lock"></lottie-interactive>
Plays animation when user clicks on animation container, plays again in reverse on second click
<lottie-interactive path="button.json" interaction="switch"></lottie-interactive>
Plays animation when container is visible
<lottie-interactive path="button.json" interaction="play-on-show"></lottie-interactive>
Plays animation once
<lottie-interactive path="button.json" interaction="play-once"></lottie-interactive>
The default state for attributes are false or null for stroke width and color.
Makes the animation loop
<lottie-interactive path="button.json" loop></lottie-interactive>
Changes the stroke width of every stroke
<lottie-interactive path="button.json" s-width="25"></lottie-interactive>
Changes the stroke color of every stroke, must be a full hexadecimal color
<lottie-interactive path="button.json" s-color="#ffffff"></lottie-interactive>
Makes the animation play automatically on load
<lottie-interactive path="button.json" autoplay></lottie-interactive>
Sets the speed of the animation
<lottie-interactive path="button.json" speed="0.5"></lottie-interactive>
Delay the loading of the animation, defined in milliseconds
<lottie-interactive path="button.json" delay="3000"></lottie-interactive>
Resets the animation to the first frame after it has finished playing
<lottie-interactive path="button.json" reset></lottie-interactive>
Define aspect ratio, default value is 'xMidYMid slice', more information here
<lottie-interactive path="button.json" aspect-ratio='xMidYMid meet'></lottie-interactive>
Currently this library is usable on modern browsers supporting Web components and Lottie.
We recommend using this library with a module bundler such as webpack.
- Color on hover
- Animation zooming
- Padding modifier
- Upgrade codebase to use Microsoft FAST