From 8414c1079b2049bcfd18b5a42bf7e9c8498b5fae Mon Sep 17 00:00:00 2001 From: Sudev Kiyada Date: Thu, 4 Dec 2025 09:20:43 +0530 Subject: [PATCH] docs --- src/components/Lottie/Lottie.mdx | 93 ++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 41 deletions(-) diff --git a/src/components/Lottie/Lottie.mdx b/src/components/Lottie/Lottie.mdx index c15630b6..292caaf2 100644 --- a/src/components/Lottie/Lottie.mdx +++ b/src/components/Lottie/Lottie.mdx @@ -11,16 +11,28 @@ The `Lottie` component uses the [dotLottie-web](https://developers.lottiefiles.c ## How to prepare Lottie files -[LottieFiles](https://lottiefiles.com/) is the official platform for creating and editing Lottie animations. The free version of LottieFiles has limited features, so [Bodymovin](https://exchange.adobe.com/apps/cc/12557/bodymovin) remains a popular, free way to export Lottie animations as JSON files. +[LottieFiles](https://lottiefiles.com/) is the official platform for creating and editing Lottie animations. The free version of LottieFiles has limited features, so [Bodymovin](https://exchange.adobe.com/apps/cc/12557/bodymovin) remains a popular, free way to export Lottie animations as JSON files. [dotLottie](https://dotlottie.io/) is another common format for Lottie files. This format bundles the Lottie JSON file and any associated assets, such as images and fonts, into a single compressed file with the extension `.lottie`. This `Lottie` component is flexible and supports both `dotLottie` and JSON Lottie files. For best performance it is recommended that you convert your Lottie JSON file into a `.zip` file by following these steps: 1. Export your Lottie animation as a JSON file using [Bodymovin](https://exchange.adobe.com/apps/cc/12557/bodymovin) or another Lottie exporter. -2. Use the [LottieFiles converter](https://lottiefiles.com/tools/lottie-to-dotlottie) to convert the JSON file into a `.lottie` file. +2. Use the [LottieFiles converter](https://lottiefiles.com/tools/lottie-to-dotlottie) to convert the JSON file into a `.lottie` file. 3. Change the file extension to `.zip` from `.lottie`. This ensures full compatibility with the Reuters graphics publisher while maintaining the benefits of dotLottie format's compression and optimisation. +## When not to use Lottie + +Lottie animations are great for lightweight, scalable animations. However, they may not be suitable for all use cases. Consider the following before using Lottie: + +- **Huge raster images**: Lottie is best suited for simple to moderately complex animations. Animations with large raster images may not render well or could lead to performance issues. In such cases, consider using a [Video](?path=/docs/components-multimedia-video--docs) component or a [ScrollerVideo](?path=/docs/components-graphics-scrollervideo--docs) component instead. + +- **Complex effects**: Some advanced effects and features available in After Effects may not be fully supported in Lottie, which could lead to discrepancies between the original design and the rendered animation. Check the [Lottie documentation](https://lottiefiles.com/supported-features) for a list of supported features. + +- **Text rendering**: Lottie renders text as vector shapes. If you need DOM text for accessibility or CSS manipulation, consider using HTML/CSS animations instead. + +- **SVG DOM manipulation**: Lottie renders animations on a canvas. If you need to manipulate individual elements of the animation using JavaScript or CSS, consider using SVG animations instead. + ## Basic demo To use the `Lottie` component, import it and provide the Lottie animation source. The height of the container defaults to `100lvh`, but you can adjust this to any valid CSS height value such as `1200px` or `200lvh` with the `height` prop. @@ -33,7 +45,6 @@ If importing the Lottie file directly into a Svelte component, make sure to appe [Demo](?path=/story/components-graphics-scrollerlottie--demo) - ```svelte - + ``` ## Switching themes @@ -210,7 +220,7 @@ The `Lottie` component can be used with the `ScrollerBase` component to create a {#snippet backgroundSnippet()} - + {/snippet} {#snippet foregroundSnippet()}
@@ -251,38 +261,39 @@ The `Lottie` component can also be used with the `LottieForeground` component to import MyLottie from './lottie/my-lottie.zip?url'; - - - - -
- - - -
-
+ + + +
+ + + +
+
- - -
+ + +
``` + ### Using with ArchieML + With the graphics kit, you'll likely get your text and prop values from an ArchieML doc... ```yaml @@ -315,8 +326,8 @@ With the graphics kit, you'll likely get your text and prop values from an Archi {} # Foreground 2: Text only - startFrame: 50 - endFrame: 100 + startFrame: 50 + endFrame: 100 # Set foreground type type: text @@ -339,7 +350,7 @@ With the graphics kit, you'll likely get your text and prop values from an Archi } from '@reuters-graphics/graphics-components'; import { assets } from '$app/paths'; - // Make an object of components to use as foregrounds + // Make an object of components to use as foregrounds const Components = $state({ Headline, }); @@ -348,7 +359,7 @@ With the graphics kit, you'll likely get your text and prop values from an Archi {#each content.blocks as block} {#if block.type == 'lottie'} - + {#each block.foregrounds as foreground} {#if foreground.type == 'text'}