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

remove animation from overlay #1847

Merged
merged 2 commits into from
Feb 28, 2023
Merged

remove animation from overlay #1847

merged 2 commits into from
Feb 28, 2023

Conversation

keithamus
Copy link
Member

Description

@langermank and I were debugging as to why Overlay seems to only work properly on my devices... when we figured out that I have prefers-reduced-motion set!

In anchored-position, the following steps happen:

  • IntersectionObserver is registered.
  • When the user clicks the button, the element is visible.
  • IntersectionObserver triggers anchored-position#update().
    • If the user has prefers-reduced-motion then no animation plays
    • If the user does not have prefers-reduced-motion then:
      • The scaleFade animation kicks in. It starts at scale(0.5) which changes the BoundingClientRect of anchored-position to be half the size.
      • The animation grows the container to scale(1)
      • The animation finishes
  • A user with animations enabled observes that the position is "off" (by exactly half the width of the container element)

There are several not-ideal solutions to all of this:

  • anchored-position can listen for animationend and call update(). This will have a "popping" effect as when the animation ends the element will reflow into position
  • The CSS for scaleFade can add padding/margin to accommodate for the change in scale, keeping a consistent BoundingClientRect. This will be very difficult to achieve in CSS alone.
  • The JS can detect if an animation is occurring via getAnimations() and if it is occuring, then call update() on each animationframe until the animation has completed. This can be very computationally expensive and may slow down animations as each frame the position will need to be recalculated
  • We remove all animations and ship that (that's this PR!)
  • We change to an animation style that does not change the BoundingClientRect - such as a fade-in animation.

@keithamus keithamus requested review from a team and camertron February 28, 2023 16:21
@changeset-bot
Copy link

changeset-bot bot commented Feb 28, 2023

🦋 Changeset detected

Latest commit: 76a9642

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/view-components Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the ruby Pull requests that update Ruby code label Feb 28, 2023
@keithamus keithamus added the skip changeset Pull requests that don't change the library output label Feb 28, 2023
@keithamus
Copy link
Member Author

Skipping changelog as #1401 hasn't been released yet.

Copy link
Contributor

@langermank langermank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving to move forward with Overlay as we can follow up with animations later! ✨

@jonrohan jonrohan merged commit 16b1626 into main Feb 28, 2023
@jonrohan jonrohan deleted the remove-animation-from-overlay branch February 28, 2023 22:39
@primer-css primer-css mentioned this pull request Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch release ruby Pull requests that update Ruby code skip changeset Pull requests that don't change the library output
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants