Giter VIP home page Giter VIP logo

dotlottie-web's Introduction

CI GitHub contributors Contributor Covenant GitHub

dotLottie Web

Streamline your web animations with LottieFiles' official players for dotLottie and Lottie animations. Designed for quick integration, these packages help developers swiftly bring animated visuals into web projects with minimal effort.

dotLottie web sample 1 dotLottie web sample 2 dotLottie web sample 3 dotLottie web sample 4

What is dotLottie?

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".

Learn more about dotLottie.

Contents

Packages

The monorepo contains the following package:

Package Description
@lottiefiles/dotlottie-web A JavaScript library for rendering Lottie and dotLottie animations in the browser or Node.js.
@lottiefiles/dotlottie-react A React component wrapper for dotlottie-web that provides a declarative API for rendering Lottie and dotLottie animations and UI controls for interacting with them.
@lottiefiles/dotlottie-wc A Web Component wrapper for dotlottie-web that provides a declarative API for rendering Lottie and dotLottie animations and UI controls for interacting with them.
@lottiefiles/dotlottie-vue A Vue component wrapper for dotlottie-web that provides a declarative API for rendering Lottie and dotLottie animations and UI controls for interacting with them.
@lottiefiles/dotlottie-svelte A Svelte component wrapper for dotlottie-web that provides a declarative API for rendering Lottie and dotLottie animations and UI controls for interacting with them.

Note: Each package has its own README.md with detailed documentation on usage and APIs.

Getting Started

To contribute to this monorepo or use its packages in your project, follow these setup steps:

Prerequisites

Ensure you have the following installed:

  • Node.js version 18 or greater
  • pnpm version 8

Setup

Clone the monorepo:

git clone https://github.com/LottieFiles/dotlottie-web.git
cd dotlottie-web

Install dependencies:

pnpm install

Live Examples

Local Examples

Discover how to implement and utilize the dotlottie-web packages with our example applications. These examples serve as a practical guide to help you understand how to integrate Lottie and dotLottie animations into your web projects.

Available examples:

  • dotlottie-web-example: A basic typescript example app of how to use @lottiefiles/dotlottie-web to render a Lottie or dotLottie animation in the browser.
  • dotlottie-web-node-example: This example demonstrates how to use the @lottiefiles/dotlottie-web in a Node.js environment. It showcases controlling animation playback, rendering frame by frame, and converting a dotLottie animation into a GIF file. for more information, see the README.

Running Examples

  • Clone the repository:
git clone https://github.com/LottieFiles/dotlottie-web.git
cd dotlottie-web
  • Install dependencies:
pnpm install
  • Build the packages:
pnpm run build
  • Run the app:
# Change directory to the example app folder
cd apps/dotlottie-web-example 
pnpm run dev

Feel free to modify and play around with the code to see how changes affect the animations.

Development

Building Packages

To build all packages within the monorepo:

pnpm run build

Running Locally

To start a local development environment for all packages:

pnpm run dev

Scripts

Here's a brief explanation of the scripts available in the root package.json:

  • build: Builds all packages using turbo.
  • changelog: Adds a changeset to generate changelog and version updates.
  • clean: Cleans up the repository by removing development artifacts.
  • dev: Runs all packages in development/watch mode.
  • format: Formats the codebase using Prettier and Remark.
  • lint: Lints the codebase using ESLint.
  • test: Runs tests across all packages.
  • type-check: Checks for TypeScript type errors.

For a full list of available scripts, see the scripts section in package.json.

Contributing

We welcome contributions to any of the packages in this monorepo. Please read our Contributing Guidelines and our Code of Conduct to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to the project.

License

MIT ยฉ LottieFiles

dotlottie-web's People

Contributors

afsalz avatar dependabot[bot] avatar hermet avatar lottiefiles-bot avatar renovate[bot] avatar theashraf avatar tinyjin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

dotlottie-web's Issues

Trim paths speed do not match original clip

Overview

Sorry for opening these many issues. We are moving from @dotlottie/player-component to @lottiefiles/dotlottie-web and we want to make sure everything works as expected. We are primarily working with this animation.

With @dotlottie/player-component it works flawlessly. However, when running the animation with @lottiefiles/dotlottie-web, some paths (trimming) go much faster than expected (only some of them). In the case of our animation, the windows of some houses are drawn too quickly. Example (I highlighted some of the mismatches in red):

example.mp4

You can check the same animation running with each package in:

Different rendering result compared to lottie-web

Overview

When rendering a simple animation from the same JSON file, the result is different when using dotlottie-web compared to lottie-web. The dotlottie-web rendering produces unexpected opaque center within the rocket:

2024-03-15 at 12 19 38

In the above example, lottie-web uses canvas renderer for fair comparison. Both use the same JSON file as a source. I tried converting JSON to dotlottie format, but it didn't change the result.

Reproduction

I created minimal reproduction that can be observed here: https://stackblitz.com/edit/vitejs-vite-2pieau?file=src%2FApp.svelte

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency @size-limit/preset-small-lib to v10.0.3
  • chore(deps): update dependency size-limit to v10.0.3
  • fix(deps): update dependency @dotlottie/dotlottie-js to v0.6.1
  • chore(deps): update dependency @size-limit/preset-small-lib to v11
  • chore(deps): update dependency remark-cli to v12
  • chore(deps): update dependency size-limit to v11
  • chore(deps): update dependency syncpack to v11
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

dockerfile
packages/web/Dockerfile
github-actions
.github/workflows/main.yml
  • styfle/cancel-workflow-action 0.12.0
  • actions/checkout v4
  • pnpm/action-setup v2
  • actions/setup-node v4
  • andresz1/size-limit-action v1
  • actions/checkout v4
  • pnpm/action-setup v2
  • actions/setup-node v4
  • changesets/action v1
  • actions/setup-node v4
  • changesets/action v1
.github/workflows/stale.yml
  • actions/stale v8
npm
apps/dotlottie-web-example/package.json
  • typescript 5.0.4
  • vite ^4.4.5
package.json
  • @changesets/cli 2.26.2
  • @commitlint/cli 17.6.1
  • @lottiefiles/commitlint-config 2.0.0
  • @lottiefiles/eslint-plugin 3.0.0
  • @lottiefiles/prettier-config 3.0.0
  • @lottiefiles/remark-preset 1.0.0
  • @lottiefiles/tsconfig 2.0.0
  • @size-limit/esbuild ^11.0.0
  • @size-limit/esbuild-why ^11.0.0
  • @size-limit/preset-small-lib ^10.0.2
  • cross-env 7.0.3
  • eslint 7.32.0
  • husky 8.0.3
  • lint-staged 13.2.1
  • npm-check-updates 16.10.9
  • prettier 2.8.8
  • remark-cli 11.0.0
  • size-limit ^10.0.2
  • syncpack 9.8.6
  • turbo 1.10.16
  • typescript 5.0.4
  • pnpm 8.10.1
packages/web/package.json
  • @dotlottie/dotlottie-js ^0.6.0
  • cross-env 7.0.3
  • tsup 7.2.0
  • typescript 5.0.4
  • node >=18
scripts/package.json
  • zx 7.0.7

  • Check this box to trigger a request for Renovate to run again on this repository

Animation does not work in DotLottie Web

Overview

Hi, I am trying to integrate this lottie animation (that I had exported from figma), https://app.lottiefiles.com/share/352a1071-0e63-44f2-9bd8-a6b94026600d, into my react app but it does not seem to work at all (it renders a blank canvas). Both the .json and .lottie formats do not seem to work.

Lottie .json: https://lottie.host/c47dca0a-2580-41b8-b2e9-75a9aeeb017b/Ja2z677E9b.json
.lottie: https://lottie.host/70cdd9e4-7e68-4166-9769-4ea6e4412fd6/GOZKlPuo9N.lottie
Codepen: https://codepen.io/tayyari/pen/wvZyXRZ

This is how it's supposed to look
Screenshot 2024-04-05 at 8 22 33โ€ฏPM

Consuming repo

What repo were you working in when this issue occurred?
dotlottie-web

...

Labels

  • [] Add the Type: Bug label to this issue.

Use DotLottie Web with Nuxt 2

Overview

  • I want to use dotLottie web player on a Nuxt 2 project. But it seems there is an issue with the file loader. I haven't found a solution for this case yet (Currently only topic related to Nuxt 3 is opened)
    Module parse failed: Unexpected token. You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
    image

  • My reproduce repo:
    Codesandbox

  • I used node v20.11.1 and nuxt 2.15.7.

So I would like to know if dotLottie currently support Nuxt 2. Thank you!

AE loopOut() does not work

Overview

I am testing an animation moving from @dotlottie/player-component to @lottiefiles/dotlottie-web. Animation link.

With @dotlottie/player-component it works flawlessly. However, when running the animation with @lottiefiles/dotlottie-web, some parts do not work. In my case, the "bike" animation at the end (which was created using the loopOut() command in AE), does not loop.

Implement a Marker Selection Control in dotLottie Viewer

It would be useful to introduce a new feature in the dotLottie Viewer that allows users to list markers available and select specific marker for playback.

dotLottie-web package currently provides an API that enables the retrieval of all markers and the loading of a specific marker. To illustrate the usage of markers within dotLottie-web, this CodePen example serves as an excellent reference: https://codepen.io/lottiefiles/pen/RwOROKp.

image

svg renderer

overview

it seems like this repo is completely based on the canvas renderer, as it requires a canvas element to function properly. are you planning to integrate the svg renderer as well at some point?

type

  • new feature
  • changes to existing features

motivation

i prefer this repo over the player component, because it is not designed as a web component and does not encapsulate its functionality within a custom <dotlottie-player> element, which unfortunately creates multiple issues on my side with my bundler and code splitting.

so this new repo seems to be making all my dreams come true. however, some of my animations are being played back filling the whole viewport, which creates performance issues and low frame rates. the svg renderer would eliminate these issues.

labels

  • Add the type: feature request label to this issue.

High CPU load

Overview

Hello. I was trying to implement animations on a site and noticed that dotlottie-web causes a huge CPU load. You can check it here: https://codepen.io/nauorama/full/LYvJOrZ. This doesn't happen with the @dotlottie/player-component library using the same animations. Can you help, please?

Screenshot 2024-04-16 at 16 50 08

Canvas width and height getting smaller on zoom level change

Overview

I am using @lottiefiles/dotlottie-react 0.3.1

import myLottie from '@/assets/myLottie.lottie?url'

<DotLottieReact
width={'600'}
height={'400'}
src={myLottie}
autoplay
loop
/>

Canvas width and height getting smaller when I change zoom level. and hits zero eventually.

  • Add the Type: Bug label to this issue.

const dpr = this._renderConfig.devicePixelRatio || window.devicePixelRatio || 1;

dotlottie-web interactivity for scroll interactions

Overview

It seems currently not possible to add scroll interactivity to .lottie files integrated with dotlottie-web. In the previous player web-component (that points to dotlottie-web, see https://github.com/dotlottie/player-component/tree/master/packages/player-component) we were able to use the lottie-interactivity library (https://github.com/LottieFiles/lottie-interactivity) to create scroll-interactions.

Motivation

to create animated .lottie files with scrolling reactivity and while using the latest dotlottie-web library, as the .lottie files seem to be much more performant than the older .json/lottie-web or player-component integrations.

Including index.css interferes with other classes Type: Bug

Overview

When including import '@dotlottie/react-player/dist/index.css'; in the application as described in the documentation, it adds some unscoped css which can interfere with application style, for example it adds the following style:

.error {
  display: flex;
  margin: auto;
  justify-content: center;
  height: 100%;
  align-items: center;
}

It's a very common class name, and using it unprefixed can cause unexpected errors in different places. In my specific case, the issue is with the margin: auto; part, but I have no guarantee it won't interfere with other class names too.
...

Consuming repo

What repo were you working in when this issue occurred?

I'm using the @dotlottie/react-player package.

Labels

  • Add the Type: Bug label to this issue.

Incorrect Path Usage in DotLottieReact Component

Description:
In the current implementation of the DotLottieReact component within the @lottiefiles/dotlottie-react library, there seems to be an inconsistency in the way paths are handled, causing confusion and potential errors for users.

Problem:
When attempting to utilize the DotLottieReact component in a Vite + React project, users are encountering issues related to incorrect path usage. Specifically, the component fails to render the Lottie animation when the src prop is assigned a relative path ("./animation.lottie"), resulting in a broken animation.

Failing Code:

import { DotLottieReact } from "@lottiefiles/dotlottie-react";

function App() {
  return <DotLottieReact src="./animation.lottie" loop autoplay />;
}

export default App;

Expected Behavior:
The DotLottieReact component should successfully render the Lottie animation when provided with a relative path to the animation file.

Working Code:

import { DotLottieReact } from "@lottiefiles/dotlottie-react";

function App() {
  return <DotLottieReact src="../src/animation.lottie" loop autoplay />;
}

export default App;

Explanation:
Upon investigation, it appears that the DotLottieReact component requires a precise path to the Lottie animation file in order to render it correctly. However, the documentation or error messages do not provide clear guidance on this requirement, leading to confusion among users.

Proposed Solution:
Documentation Improvement: Enhance the documentation of the @lottiefiles/dotlottie-react library to explicitly specify the correct path usage for the src prop, providing examples and explanations to guide users effectively.

Error Handling: Implement more informative error messages within the library that notify users when an incorrect path is provided to the DotLottieReact component, helping them identify and resolve issues more efficiently.

Additional Information:
Library Version: 0.5.1
Environment: Vite + React + JS (in Visual Studio Code)
Operating System: Windows 10

This issue seeks to improve the usability and reliability of the @lottiefiles/dotlottie-react library, ensuring a smoother experience for developers integrating Lottie animations into their Vite + React projects. Any assistance or clarification on this matter would be greatly appreciated. Thank you.

Dotlottie sometimes skips frames and lags Type: Bug

Overview

Hey,
so I've added a preloader to my shopify website and used the dotlottie animation. It's only shown once in a session and only on the main page.
Via HTML I preload the .lottie file and the animation plays, after the DOM Content has completely loaded, to ensure, the timer syncs with the animation.

My html:

<div id="loader">
<dotlottie-player background="transparent" id="lottie-loader" speed="1" style="width: 50%; height: 50%" direction="1" mode="normal" loop autoplay></dotlottie-player>
</div>

<link rel="preload" fetchpriority="high" href="https://lottie.host/a276f20a-2888-4dc0-a098-2edf62682b4c/WtaeCDO9ti.lottie" type="application/json">

My javascript

preloader.js

  const loader = document.getElementById("loader");
  $('#loader').hide();
}

$(document).ready(function() {
  if (document.cookie.indexOf("preloaderShown=true") === -1) {
      document.cookie = "preloaderShown=true; path=/";
    window.onload = function() {
      const player = document.querySelector('dotlottie-player');
    player.load('https://lottie.host/a276f20a-2888-4dc0-a098-2edf62682b4c/WtaeCDO9ti.lottie');
      setTimeout(function() {
      hidePreloader();
    }, 3100);
    };
    
The animation hides, after the preloader has completely loaded.

} else {
    // If the preloader has already been shown in this session, hide it immediately
    $('#loader').hide();
  }
});

The Problem

Sometimes the animation skips some frames and lags, especially on mobile devices. It doesn't matter if your connection is slow or fast, since the animation only loads after the page is completely loaded.

How it looks when it bugs:

RPReplay_Final1704895547.MP4

How it should look like:

RPReplay_Final1704895617.MP4

This is also reproduceable on desktop. Sometimes it lags, sometimes not. Hope some1 can help me.

Consuming repo

What repo were you working in when this issue occurred?

<script src="https://unpkg.com/@dotlottie/player-component@latest/dist/dotlottie-player.mjs" type="module"></script>

...

Labels

  • Add the Type: Bug label to this issue.

adobe lottie json

hello

adobe after effect movin and lottie json file can work here ?

as some image and text level dynamic template possible and convert to video ?

int his script possible or anyone can help us how to possible make dynamic tempalte so based on user we can process to mp4

currently in adobe we getting png with base64 raw format and other text how to modify dont know

`play()` after `setFrame()` resets the animation

Overview

Using @lottiefiles/dotlottie-web, calling play() after setFrame() resets the currentFrame property and restarts the animation from the start. This does not match the documentation for play(): Begins playback from the current animation position.

import { DotLottie } from "https://cdn.jsdelivr.net/npm/@lottiefiles/dotlottie-web/+esm";
(() => {
// Get lottie player and set the animation to play from half way through when finished a loop
const canvas = document.getElementById('hero-lottie');
const player = new DotLottie({
autoplay: true,
loop: false,
canvas: canvas,
speed: 1,
src: canvas.getAttribute('data-src'),
});
// Get loopFrom attribute
const loopFrom = parseInt(canvas.getAttribute('loopFrom'));
player.addEventListener('complete', () => {
    player.setFrame(loopFrom);
    player.play(); // Here the animation resets to the frame 0
});
})();

A workaround is to call player.setFrame() after play().

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.