Skip to content

Commit

Permalink
feat: lottie interactivity added
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 73b39d3aaea2613705ae8fc145acbaf4181fbd11
  • Loading branch information
abbas-nazar authored and actions-user committed Oct 23, 2024
1 parent 531a47e commit 4660cb0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion plasmicpkgs/lottie-react/src/Lottie.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CodeComponentMeta, PlasmicCanvasContext } from "@plasmicapp/host";
import registerComponent from "@plasmicapp/host/registerComponent";
import Lottie from "lottie-react";
import Lottie, { InteractivityProps } from "lottie-react";
import React, { useContext } from "react";

const isBrowser = typeof window !== "undefined";
Expand Down Expand Up @@ -417,6 +417,7 @@ interface CommonLottieWrapperProps {
loop?: boolean;
autoplay?: boolean;
preview?: boolean;
interactivity?: Omit<InteractivityProps, "lottieObj"> | undefined;
}

export interface LottieWrapperProps extends CommonLottieWrapperProps {
Expand All @@ -429,6 +430,7 @@ export interface AsyncLottieWrapperProps extends CommonLottieWrapperProps {
export function LottieWrapper({
className,
animationData,
interactivity,
loop = true,
autoplay = true,
preview = false,
Expand All @@ -446,6 +448,7 @@ export function LottieWrapper({
<Lottie
className={className}
animationData={animationData}
interactivity={interactivity}
loop={loop}
autoplay={inEditor ? preview : autoplay}
/>
Expand Down Expand Up @@ -481,6 +484,7 @@ async function fetchAnimationData(url: string) {
export function AsyncLottieWrapper({
className,
animationUrl,
interactivity,
loop = true,
autoplay = true,
preview = false,
Expand Down Expand Up @@ -520,6 +524,7 @@ export function AsyncLottieWrapper({
<Lottie
className={className}
animationData={data}
interactivity={interactivity}
loop={loop}
autoplay={inEditor ? preview : autoplay}
/>
Expand All @@ -531,6 +536,12 @@ export function registerLottieWrapper(loader?: {
registerComponent: typeof registerComponent;
}) {
const commonProps: CodeComponentMeta<CommonLottieWrapperProps>["props"] = {
interactivity: {
type: "object",
description: "Animation interactivity JSON data",
helpText:
"For more information on interactivity, visit the Lottie React [documentation](https://lottiereact.com/components/Lottie#interactivity-1)",
},
loop: {
type: "boolean",
description: "Whether to loop the animation",
Expand Down

0 comments on commit 4660cb0

Please sign in to comment.