Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to construct 'ImageData': The source width is zero or not a number. #260

Open
sulram opened this issue Jun 21, 2024 · 3 comments
Open
Labels
question Further information is requested react

Comments

@sulram
Copy link

sulram commented Jun 21, 2024

Overview

Error that's occuring wrapper with display:none and framer motion of a <DotLottieReact /> component

Failed to construct 'ImageData': The source width is zero or not a number.

Sometimes

Consuming repo

What repo were you working in when this issue occurred?

@lottiefiles/dotlottie-react

@theashraf
Copy link
Member

Hi @sulram, when using display: none, the width and height of the DotLottieReact canvas are set to zero, causing the error.

You can use the hidden prop directly on the DotLottieReact component. This keeps the component in the DOM without rendering it visibly:

<DotLottieReact hidden ... />

also you can use other CSS properties like visibility or opacity:

<DotLottieReact style={{ visibility: 'hidden' }} ... />
<DotLottieReact style={{ opacity: 0 }} ... />

@theashraf theashraf added question Further information is requested react labels Jun 22, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.

@github-actions github-actions bot added the stale label Aug 22, 2024
@Idowu-Adelekee
Copy link

I experience this issue with Web using vanilla JS, but the parent element also need to be set to display none because I'm working on a mobile nav which at the desktop screen should be hidden. Is there any other workaround to it?

@github-actions github-actions bot removed the stale label Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested react
Projects
None yet
Development

No branches or pull requests

3 participants