Skip to content

Is there a way defer DOM item while it's outside on the screen. #137

Closed Answered by shinsenter
ionurboz asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @ionurboz

I genuinely still don't fully understand your question.

The functionality of Defer.dom() is closely tied to the IntersectionObserver API supported by browsers. This requires the DOM elements to have at least 1px visible on the webpage (whether inside or outside the viewport). Therefore, you cannot defer DOM elements that are hidden (those with attributes like display:none, visibility:hidden, or <input type="hidden">, etc.).

Additionally, if you want to reveal an element before it enters the viewport, you can pass Intersection observer options (for example, {rootMargin: '200%'}) to the 5th argument of the Defer.dom() to reveal the element before it enters the viewport.

You can…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ionurboz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #136 on July 12, 2024 15:47.