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

Improve performance during resize #247

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

Conversation

johannesodland
Copy link
Contributor

@johannesodland johannesodland commented Feb 12, 2024

(Addressing #239)

For each source element multiple elements are currently observed using ResizeObserver:

  • the source and its direct children
  • every subject where the source is the nearest scroll container.

The resize observer callback invokes updateMeasurements()

As a result updateMeasurements() might be called multiple times for each source element when resize observations are broadcasted. Currently, only the task to update timelines and animations is throttled. However, if there are multiple view timelines for the same source, the source and subject elements can be measured multiple times per resize update.

If updateMeasurements() has already been called, there's no reason to update the measurements until after the next animation frame. This PR throttles measurements during the resize observation broadcast by setting a flag once updateMeasurements() has been called for a source, and then clearing it at the start of the next animation frame.

@johannesodland johannesodland force-pushed the improve-performance-during-resize branch from be07f1f to dcd8aba Compare February 13, 2024 06:09
@johannesodland johannesodland marked this pull request as ready for review February 13, 2024 06:30
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