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

Elements are not being animated after building, works fine in dev server #50

Open
DarthGigi opened this issue Jul 6, 2024 · 5 comments

Comments

@DarthGigi
Copy link

Elements are not being animated after building the project. In a development server, they are being animated.

I've made a minimal repro: https://stackblitz.com/edit/sveltejs-kit-template-default-gmkp1v

  • If you run npm run dev, you will see that the text is being animated
  • If you run npm run build && npm run preview, you will see that the text does not animate and just pops into existence

I'm not sure if I'm missing something or doing something wrong?

@candidosales
Copy link

candidosales commented Sep 2, 2024

Hi @DarthGigi , you should use:

	import Motion from 'svelte-motion/src/motion/MotionSSR.svelte';

In the introduction explaining about this: https://svelte-motion.gradientdescent.de/ (SvelteKit section)

@DarthGigi
Copy link
Author

DarthGigi commented Sep 3, 2024

Hi @candidosales, thank you so much for your reply! I somehow missed that part in the docs 😅 . I still have a small problem: the initial="hidden" attribute doesn't work anymore for some reason. The text is visible when the page loads and then does the animation, instead of being invisible and animating to visible.

I have updated my minimal repro: https://stackblitz.com/edit/sveltejs-kit-template-default-gmkp1v
When you refresh the preview page you can see that the text isn't hidden before the animation.

Screenshot.2024-09-03.at.09.23.56.PM.mp4
How it should work:
Screenshot.2024-09-03.at.09.26.04.PM.mp4

Any idea on what could be the issue and/or how to fix it?

@candidosales
Copy link

candidosales commented Sep 4, 2024

@DarthGigi , I think you can use opacity to control the visibility:

  <Motion let:motion key={i} initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }}  variants={framerProps} transition={{ duration, delay: i * delayMultiple }}>

https://stackblitz.com/edit/sveltejs-kit-template-default-mpqaxf?file=src%2Flib%2Fcomponents%2Fgradual-spacing.svelte

Another suggestion, you can use animejs is lighter than svelte motion library and you can find many examples of how animate letters: https://tobiasahlin.com/moving-letters/

@DarthGigi
Copy link
Author

@candidosales Thanks for you reply again! Your suggestion didn't work unfortunately, the text is still visible on page load and opacity actually broke in the letters sliding in from the right. Do you have any other ideas?

@suyash172003
Copy link

Hi @DarthGigi,

I think we can solve this by managing the transition time. I have increased the duration to 1.5 seconds. Please check and let me know your thoughts.

Screenshot 2024-12-01 015045

https://stackblitz.com/edit/sveltejs-kit-template-default-bjep6y?file=src%2Flib%2Fcomponents%2Fgradual-spacing.svelte

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants