[web-php] master: Pause hero background animation while it is offscreen
| From: | Theodore Brown via Derick Rethans | Date: | Tue, 17 Nov 2026 15:39:19 +0000 |
| Subject: | [web-php] master: Pause hero background animation while it is offscreen | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-34194@lists.php.net to get a copy of this message | ||
Author: Theodore Brown (theodorejb)
Committer: Derick Rethans (derickr)
Date: 2026-11-17T15:39:00Z
Commit: https://github.com/php/web-php/commit/9d7f4fb6a40ca83440fff6e74a6982d1cc1b5e11
Raw diff: https://github.com/php/web-php/commit/9d7f4fb6a40ca83440fff6e74a6982d1cc1b5e11.diff
Pause hero background animation while it is offscreen
Even when the hero is scrolled out of view, the browser keeps ticking the orb animations on the
compositor every frame. An IntersectionObserver now toggles a paused class on the hero background so
the animations stop while it isn't visible and resume from the same position when it scrolls
back into view.
Changed paths:
M public/styles/php85.css
M src/Themes/ReleasePage.php
Diff:
diff --git a/public/styles/php85.css b/public/styles/php85.css
index ff3cdbd60c..5d957f6239 100644
--- a/public/styles/php85.css
+++ b/public/styles/php85.css
@@ -528,6 +528,11 @@ a {
@keyframes hero-orb-rotate-fwd { from { transform: rotate(0deg) } to { transform: rotate(360deg) }
}
@keyframes hero-orb-rotate-rev { from { transform: rotate(360deg) } to { transform: rotate(0deg) }
}
+.hero-bg.paused .hero-orb,
+.hero-bg.paused .hero-orb div {
+ animation-play-state: paused
+}
+
@media (prefers-reduced-motion: reduce) {
.hero-orb,
.hero-orb div {
diff --git a/src/Themes/ReleasePage.php b/src/Themes/ReleasePage.php
index cc11737342..2737238a43 100644
--- a/src/Themes/ReleasePage.php
+++ b/src/Themes/ReleasePage.php
@@ -114,6 +114,14 @@ public static function getPrefooter(string $title, string $upgradeNow, string
$d
</svg>
<script>
+ // Pause the hero background animation while it is scrolled out of view.
+ const heroBg = document.querySelector('.hero-bg');
+ if (heroBg && 'IntersectionObserver' in window) {
+ new IntersectionObserver(([entry]) => {
+ heroBg.classList.toggle('paused', !entry.isIntersecting);
+ }).observe(heroBg);
+ }
+
document.addEventListener('DOMContentLoaded', () => {
document.addEventListener('click', async (e) => {
const btn = e.target.closest('.js-copy-code');