GithubHelp home page GithubHelp logo

Comments (7)

thisispaul avatar thisispaul commented on May 23, 2024

Same issue and it actually just seems to completely freeze the page.

from react-fast-marquee.

timothygachengo avatar timothygachengo commented on May 23, 2024

from react-fast-marquee.

thisispaul avatar thisispaul commented on May 23, 2024

I tried that and it still doesn't work.

yeah i deleted my comment as it seemed to work but then actually just broke again. sorry for confusion.

from react-fast-marquee.

thisispaul avatar thisispaul commented on May 23, 2024

I had a quick look at the code and ran some tests and it looks like the issue is here:

const resizeObserver = new ResizeObserver(() => calculateWidth());
resizeObserver.observe(containerRef.current);
resizeObserver.observe(marqueeRef.current);

This calculateWidth is being called over and over again. Each time it doubles the multiplier.

I'm guessing this is because its adding new copies which changes the width and then the resize observer is called. This ends up creating thousands of copies which grinds the page to a halt.

from react-fast-marquee.

thisispaul avatar thisispaul commented on May 23, 2024

@timothygachengo I fixed it locally by cloning the poackage and changing that whole resize observer this

  // Calculate width and multiplier on mount and on window resize
  useEffect(() => {
    if (!isMounted) return;
    calculateWidth();
    window.addEventListener("resize", calculateWidth);
    return () => window.removeEventListener("resize", calculateWidth);
  }, [calculateWidth, containerRef, isMounted]);

It's not as ideal as the original code as it will call calculateWidth more but it doesn't have the same issue of infinitely calling itself and breaking the page.

from react-fast-marquee.

wayneslabs avatar wayneslabs commented on May 23, 2024

I'm not sure if it works for nextjs, but you can try the answer described here: #66 (comment)

from react-fast-marquee.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.