#React Fast Marquee breaks with Astro View Transitions

47 messages · Page 1 of 1 (latest)

frail blaze
#

When navigating away and then coming back to a page, react-fast-marquee stops working.

The component is loaded with client:only="react" and Astro View Transitions are enabled.

What's the correct way to fix this?

dull zodiac
#

I don't use React myself, but I have experienced the same issue in the past.

It was caused by defining variables in a DOMContentLoaded event, which only fires once if you use view transitions. Use astro:page-load instead

#

Are you seeing any errors in your console?

dull zodiac
frail blaze
dull zodiac
#

I don't use React and don't know how to solve it for you since you're not using a <script> tag.

wheat sparrowBOT
#

Houston, we have a problem... and <@&1129102257422610512>, you’re our mission control! 🚀

slate raptor
# frail blaze no worries, thanks tho <:houston_salute:1164943686665257093>

have you tried using useEffect on your component?

⁨```jsx

const [key, setKey] = useState(0);

useEffect(() => {
const handlePageLoad = () => {
setKey(prev => prev + 1);
};

document.addEventListener('astro:page-load', handlePageLoad);

return () => {
  document.removeEventListener('astro:page-load', handlePageLoad);
};

}, []);

frail blaze
slate raptor
#

hmmmm

slate raptor
#

the last commit was 2 years ago.

frail blaze
#

yeah but its getting 300k weekly downloads so like i thought lets use it houston_sweat_smile

slate raptor
#

i see

#

here's an alternative

#

if you wanna try it

dull zodiac
arctic mesa
#

It could be a regression within <ClientRouter/> anyway you could make an issue with a reproduction?

frail blaze
frail blaze
# slate raptor https://ui.full.dev/docs/components/marquee/

this mostly works but I want a true full-width marquee. with auto-fill it stretches to the viewport but the spacing between items grows instead of repeating the content, which kinda breaks the marquee effect. any idea how to handle this properly?

slate raptor
#

do you have a public repo?

knotty quiver
#

Recently made one at work

dull zodiac
#

I made one recently but it was just an Embla carousel with autoplay. Looks like a marquee though

knotty quiver
#

I just built mine in solid, no reason for a library imo

fiery sparrow
#

can simply do it in base JS as well

frail blaze
# slate raptor i'm not getting what you mean tbh

with that marquee component, it doesntt repeat the items to fill the screen.
instead it just makes the space between the items bigger. because of that, the scrolling doesnt look smooth, it just looks stretched.

frail blaze
slate raptor
knotty quiver
#

Also keep in mind you may want to have a maximum width to your marquee

It looks really weird having it go all the way to the edges of a 4k or ultrawide resolution with the rest of the content usually being more centered

#

For sub 2k screens mine takes the full width but that's the biggest it gets, any bigger viewports and it fades nicely into the background at that same 2k width

frail blaze
sweet tinsel
frail blaze
sweet tinsel
#

I could fix it but it was modifiying the shadcn components

#

I had a toaster -> I did it as Astro component

#

And I had a drawer, I just added my own animation transitions there

frail blaze
#

also on the latest accordion component from shadcn the animation is missing did u check it

sweet tinsel
#

Nope, I didn't see it. I'm not using it in this project

#

But it can be probably be broken aswel yeah

#

adding this into the drawer component fixed it. if u have problems with the accordion, maybe with this you can make it work, or make some tweaks to make it work

#

note that the first animation will be different than the second animation when changing pages, but at least there's one