containers / containers/podman.io

perf: PlayOnScroll uses an unthrottled scroll listener instead of IntersectionObserver

Open
#656 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
108
Forks
188
Avg merge
9d 15h
Merged PRs (30d)
11

Description

What's happening:
src/components/utilities/PlayOnScroll/index.tsx attaches a scroll listener directly to window. On every scroll event, it calls videoRef.current.getBoundingClientRect() ,a synchronous layout read , to decide whether to play() or pause() the video.

Why it matters:
This component is mounted 4 times on /features (ManageContainersUISection, BuildImagesUISection, CreatePodsUISection, DeployToKubernetesUISection), so scrolling that page fires 4 layout reads per scroll tick instead of relying on the browser's native visibility-detection API.

How to reproduce:
1. Open podman.io/features (or run yarn start locally)
2. Open Chrome DevTools → Performance tab → record
3. Scroll through the "Manage containers / Build images / Create pods / Deploy to Kubernetes" section for a few seconds
4. Stop recording, open the Bottom-Up tab, sort by Total Time
5. Confirm getBoundingClientRect, handleScroll (index.tsx:1:1), and pause all appear with measurable main-thread time, tied to the scroll events

Image

Suggested fix:
Replace the window scroll listener + getBoundingClientRect() check with a single IntersectionObserver per instance (threshold: 1 to match the existing "fully visible" condition).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in src/components/utilities/PlayOnScroll/index.tsx and inspect how the component currently responds to window scroll events and checks video visibility. Run yarn start and use the Chrome DevTools Performance tab while scrolling /features to establish the current behavior. Done means each instance uses an IntersectionObserver with threshold 1 and no longer relies on the unthrottled scroll listener or getBoundingClientRect() check.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, performance
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.