Skip to content

feat(core): add scrollMargin to @defer viewport options - #70187

Open
SkyZeroZx wants to merge 1 commit into
angular:mainfrom
SkyZeroZx:feat-viewport-scrollMargin
Open

feat(core): add scrollMargin to @defer viewport options#70187
SkyZeroZx wants to merge 1 commit into
angular:mainfrom
SkyZeroZx:feat-viewport-scrollMargin

Conversation

@SkyZeroZx

Copy link
Copy Markdown
Contributor

Allow scrollMargin to be configured for @defer viewport, prefetch, and hydrate triggers.

Unlike rootMargin, scrollMargin expands the clipping bounds of nested scroll containers. This allows deferred content to be loaded or prefetched before it enters the visible area of a nested scroller.

Include scrollMargin in the IntersectionObserver cache key so viewport triggers with different margins use the correct observer configuration.

@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: core Issues related to the framework runtime requires: TGP This PR requires a passing TGP before merging is allowed labels Aug 13, 2026
@ngbot ngbot Bot added this to the Backlog milestone Aug 13, 2026
@SkyZeroZx
SkyZeroZx marked this pull request as ready for review August 13, 2026 21:57
@SkyZeroZx
SkyZeroZx marked this pull request as draft August 13, 2026 21:58
@SkyZeroZx
SkyZeroZx marked this pull request as ready for review August 13, 2026 21:58
@JeanMeche
JeanMeche requested a review from crisbeto August 14, 2026 13:45
@crisbeto

Copy link
Copy Markdown
Member

This is breaking our internal tests, because scrollMargin isn't part of the typings for the IntersectionObserver.

@SkyZeroZx

SkyZeroZx commented Aug 16, 2026

Copy link
Copy Markdown
Contributor Author

This is breaking our internal tests, because scrollMargin isn't part of the typings for the IntersectionObserver.

If I remember correctly, scrollMargin was added in TypeScript 6.0. Maybe G3 is using an older version of TypeScript?

While adding it to the types manually might be an alternative, I'm not sure if there would be any problems or if it should only be done in G3. Or should it be done on the Angular side?

Comment thread packages/core/primitives/defer/src/triggers.ts Outdated
@JeanMeche
JeanMeche force-pushed the feat-viewport-scrollMargin branch from 07afc2b to 358521f Compare August 16, 2026 17:42
Allow `scrollMargin` to be configured for `@defer` viewport, prefetch, and
hydrate triggers.

Unlike `rootMargin`, `scrollMargin` expands the clipping bounds of nested scroll
containers. This allows deferred content to be loaded or prefetched before it
enters the visible area of a nested scroller.

Include `scrollMargin` in the IntersectionObserver cache key so viewport
triggers with different margins use the correct observer configuration.
@SkyZeroZx
SkyZeroZx force-pushed the feat-viewport-scrollMargin branch from 358521f to 1b512bf Compare August 16, 2026 19:36
@JeanMeche JeanMeche removed area: core Issues related to the framework runtime detected: feature PR contains a feature commit labels Aug 16, 2026
@ngbot ngbot Bot removed this from the Backlog milestone Aug 16, 2026
@JeanMeche JeanMeche added the area: core Issues related to the framework runtime label Aug 16, 2026
@ngbot ngbot Bot added this to the Backlog milestone Aug 16, 2026
@JeanMeche

Copy link
Copy Markdown
Member

Passing TGP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Issues related to the framework runtime requires: TGP This PR requires a passing TGP before merging is allowed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants