Skip to content

Adding requestAnimationFrame() to scroll sniffing for better perf#1828

Merged
HardeepAsrani merged 1 commit intoCodeinwp:developmentfrom
rtvenge:fix/scroll-perf
Aug 31, 2023
Merged

Adding requestAnimationFrame() to scroll sniffing for better perf#1828
HardeepAsrani merged 1 commit intoCodeinwp:developmentfrom
rtvenge:fix/scroll-perf

Conversation

@rtvenge
Copy link
Copy Markdown
Contributor

@rtvenge rtvenge commented Aug 24, 2023

Closes Issue: (n/a)

Summary

Added requestAnimationFrame() API to scroll sniffing for better performance. Source: https://css-tricks.com/using-requestanimationframe/

Edit by Hardeep: Details: https://wordpress.org/support/topic/performance-feature-request/#post-16998512

Screenshots


Test instructions

  1. Add an animation to a black that is out of viewport onLoad.
  2. Load the page with the animation.
  3. Ensure the animation fires appropriately

Checklist before the final review

  • Included E2E or unit tests for the changes in this PR.
  • Visual elements are not affected by independent changes.
  • It is at least compatible with the minimum WordPress version.
  • It loads additional script in frontend only if it is required.
  • Does not impact the Core Web Vitals.
  • In case of deprecation, old blocks are safely migrated.
  • It is usable in Widgets and FSE.
  • Copy/Paste is working if the attributes are modified.
  • PR is following the best practices

See WordPress.org Support Thread for full context.

Please let me know if there are

@HardeepAsrani HardeepAsrani changed the base branch from master to development August 25, 2023 04:03
@Soare-Robert-Daniel
Copy link
Copy Markdown
Contributor

Everything is ok.

Tested with Chrome, Vivaldi, Firefox, and Safari.

Test blocks:

<!-- wp:themeisle-blocks/circle-counter {"id":"wp-block-themeisle-blocks-circle-counter-636dab1a","className":"animated rollIn delay-1s slower"} -->
<div id="wp-block-themeisle-blocks-circle-counter-636dab1a" data-percentage="50" data-duration="2" data-height="100" data-stroke-width="10" class="wp-block-themeisle-blocks-circle-counter animated rollIn delay-1s slower"><div class="wp-block-themeisle-blocks-circle-counter-title__area"><span class="wp-block-themeisle-blocks-circle-counter-title__value">Skill</span></div><div class="wp-block-themeisle-blocks-circle-counter__bar"></div></div>
<!-- /wp:themeisle-blocks/circle-counter -->

<!-- wp:themeisle-blocks/circle-counter {"id":"wp-block-themeisle-blocks-circle-counter-f925f2c0","className":"animated rollIn delay-1s slower"} -->
<div id="wp-block-themeisle-blocks-circle-counter-f925f2c0" data-percentage="50" data-duration="2" data-height="100" data-stroke-width="10" class="wp-block-themeisle-blocks-circle-counter animated rollIn delay-1s slower"><div class="wp-block-themeisle-blocks-circle-counter-title__area"><span class="wp-block-themeisle-blocks-circle-counter-title__value">Skill</span></div><div class="wp-block-themeisle-blocks-circle-counter__bar"></div></div>
<!-- /wp:themeisle-blocks/circle-counter -->

<!-- wp:spacer {"height":"407px"} -->
<div style="height:407px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:themeisle-blocks/circle-counter {"id":"wp-block-themeisle-blocks-circle-counter-8a4b5137","className":"animated rollIn delay-1s slower"} -->
<div id="wp-block-themeisle-blocks-circle-counter-8a4b5137" data-percentage="50" data-duration="2" data-height="100" data-stroke-width="10" class="wp-block-themeisle-blocks-circle-counter animated rollIn delay-1s slower"><div class="wp-block-themeisle-blocks-circle-counter-title__area"><span class="wp-block-themeisle-blocks-circle-counter-title__value">Skill</span></div><div class="wp-block-themeisle-blocks-circle-counter__bar"></div></div>
<!-- /wp:themeisle-blocks/circle-counter -->

<!-- wp:themeisle-blocks/circle-counter {"id":"wp-block-themeisle-blocks-circle-counter-23e08039","className":"animated slideInRight delay-1s slower"} -->
<div id="wp-block-themeisle-blocks-circle-counter-23e08039" data-percentage="50" data-duration="2" data-height="100" data-stroke-width="10" class="wp-block-themeisle-blocks-circle-counter animated slideInRight delay-1s slower"><div class="wp-block-themeisle-blocks-circle-counter-title__area"><span class="wp-block-themeisle-blocks-circle-counter-title__value">Skill</span></div><div class="wp-block-themeisle-blocks-circle-counter__bar"></div></div>
<!-- /wp:themeisle-blocks/circle-counter -->

<!-- wp:themeisle-blocks/circle-counter {"id":"wp-block-themeisle-blocks-circle-counter-66251391","className":"animated slideInDown delay-200ms faster"} -->
<div id="wp-block-themeisle-blocks-circle-counter-66251391" data-percentage="50" data-duration="2" data-height="100" data-stroke-width="10" class="wp-block-themeisle-blocks-circle-counter animated slideInDown delay-200ms faster"><div class="wp-block-themeisle-blocks-circle-counter-title__area"><span class="wp-block-themeisle-blocks-circle-counter-title__value">Skill</span></div><div class="wp-block-themeisle-blocks-circle-counter__bar"></div></div>
<!-- /wp:themeisle-blocks/circle-counter -->

<!-- wp:themeisle-blocks/circle-counter {"id":"wp-block-themeisle-blocks-circle-counter-1b1d1ca3","className":"animated slideInUp delay-200ms faster"} -->
<div id="wp-block-themeisle-blocks-circle-counter-1b1d1ca3" data-percentage="50" data-duration="2" data-height="100" data-stroke-width="10" class="wp-block-themeisle-blocks-circle-counter animated slideInUp delay-200ms faster"><div class="wp-block-themeisle-blocks-circle-counter-title__area"><span class="wp-block-themeisle-blocks-circle-counter-title__value">Skill</span></div><div class="wp-block-themeisle-blocks-circle-counter__bar"></div></div>
<!-- /wp:themeisle-blocks/circle-counter -->

<!-- wp:themeisle-blocks/circle-counter {"id":"wp-block-themeisle-blocks-circle-counter-54835b6e","className":"animated bounceInRight delay-200ms faster"} -->
<div id="wp-block-themeisle-blocks-circle-counter-54835b6e" data-percentage="50" data-duration="2" data-height="100" data-stroke-width="10" class="wp-block-themeisle-blocks-circle-counter animated bounceInRight delay-200ms faster"><div class="wp-block-themeisle-blocks-circle-counter-title__area"><span class="wp-block-themeisle-blocks-circle-counter-title__value">Skill</span></div><div class="wp-block-themeisle-blocks-circle-counter__bar"></div></div>
<!-- /wp:themeisle-blocks/circle-counter -->

<!-- wp:themeisle-blocks/circle-counter {"id":"wp-block-themeisle-blocks-circle-counter-2b219f3a","className":"animated bounceInDown delay-200ms faster"} -->
<div id="wp-block-themeisle-blocks-circle-counter-2b219f3a" data-percentage="50" data-duration="2" data-height="100" data-stroke-width="10" class="wp-block-themeisle-blocks-circle-counter animated bounceInDown delay-200ms faster"><div class="wp-block-themeisle-blocks-circle-counter-title__area"><span class="wp-block-themeisle-blocks-circle-counter-title__value">Skill</span></div><div class="wp-block-themeisle-blocks-circle-counter__bar"></div></div>
<!-- /wp:themeisle-blocks/circle-counter -->

<!-- wp:themeisle-blocks/circle-counter {"id":"wp-block-themeisle-blocks-circle-counter-e5648e54","className":"animated rotateIn delay-200ms faster"} -->
<div id="wp-block-themeisle-blocks-circle-counter-e5648e54" data-percentage="50" data-duration="2" data-height="100" data-stroke-width="10" class="wp-block-themeisle-blocks-circle-counter animated rotateIn delay-200ms faster"><div class="wp-block-themeisle-blocks-circle-counter-title__area"><span class="wp-block-themeisle-blocks-circle-counter-title__value">Skill</span></div><div class="wp-block-themeisle-blocks-circle-counter__bar"></div></div>
<!-- /wp:themeisle-blocks/circle-counter -->

<!-- wp:themeisle-blocks/circle-counter {"id":"wp-block-themeisle-blocks-circle-counter-8ee1e7a1","className":"animated swing delay-1s slow"} -->
<div id="wp-block-themeisle-blocks-circle-counter-8ee1e7a1" data-percentage="50" data-duration="2" data-height="100" data-stroke-width="10" class="wp-block-themeisle-blocks-circle-counter animated swing delay-1s slow"><div class="wp-block-themeisle-blocks-circle-counter-title__area"><span class="wp-block-themeisle-blocks-circle-counter-title__value">Skill</span></div><div class="wp-block-themeisle-blocks-circle-counter__bar"></div></div>
<!-- /wp:themeisle-blocks/circle-counter -->

<!-- wp:themeisle-blocks/circle-counter {"id":"wp-block-themeisle-blocks-circle-counter-fd8e6202","className":"animated jackInTheBox delay-200ms slow"} -->
<div id="wp-block-themeisle-blocks-circle-counter-fd8e6202" data-percentage="50" data-duration="2" data-height="100" data-stroke-width="10" class="wp-block-themeisle-blocks-circle-counter animated jackInTheBox delay-200ms slow"><div class="wp-block-themeisle-blocks-circle-counter-title__area"><span class="wp-block-themeisle-blocks-circle-counter-title__value">Skill</span></div><div class="wp-block-themeisle-blocks-circle-counter__bar"></div></div>
<!-- /wp:themeisle-blocks/circle-counter -->

@irinelenache
Copy link
Copy Markdown
Contributor

@Soare-Robert-Daniel Can you please help me with the zip build for this PR?

@Soare-Robert-Daniel
Copy link
Copy Markdown
Contributor

@irinelenache
Copy link
Copy Markdown
Contributor

@Soare-Robert-Daniel Tested and everything's fine on my end 🚀

Thank you @rtvenge 🙏

@HardeepAsrani HardeepAsrani merged commit d12d6c5 into Codeinwp:development Aug 31, 2023
@pirate-bot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.4.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@pirate-bot pirate-bot added the released Indicate that an issue has been resolved and released in a particular version of the product. label Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Indicate that an issue has been resolved and released in a particular version of the product.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding requestAnimationFrame() to scroll sniffing for better perf

5 participants