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

Fix: Prevent scrollbars from flashing on resize #305

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lancesnider
Copy link
Contributor

The Problem

When the Rive component is full width/height and you resize the page, you sometimes see the scrollbars flash on/off. When you zoom in on your browser, sometimes it gets stuck in a loop the scrollbars flashing on/off.

CleanShot 2024-11-15 at 09 50 09
CleanShot 2024-11-15 at 09 50 37

Why is this happening?

rive-react listens for a window resize then updates the canvas CSS width/height. There's an instant when the page has a new width, but the CSS hasn't updated yet.

When you zoom in to a certain level, it looks like it triggers another resize every time the scrollbars appear or disappear.

The fix

Add overflow: hidden to the container div that holds the canvas element.

CleanShot 2024-11-14 at 21 26 32
CleanShot 2024-11-14 at 21 27 13

Testing

There are 2 new tests:

  • Make sure the container includes the overflow: hidden CSS style
  • If the user includes a className in the <RiveComponent>, make sure we don't include the new CSS style

Run npm test

Other things to test:

  • Check out each of the existing examples to make sure nothing changed
  • Scale a fullscreen rive element to make sure you don't see scrollbars
  • Cmd +/- a fullscreen rive element to make sure you don't see scrollbars

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

Successfully merging this pull request may close these issues.

1 participant