Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
b11ba67e
Commit
b11ba67e
authored
Jul 12, 2025
by
Ian Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
even simpler
parent
3825e4a6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
layout-router.tsx
packages/next/src/client/components/layout-router.tsx
+6
-4
No files found.
packages/next/src/client/components/layout-router.tsx
View file @
b11ba67e
...
@@ -120,12 +120,10 @@ function findDOMNode(
...
@@ -120,12 +120,10 @@ function findDOMNode(
* Check if a HTMLElement is hidden or fixed/sticky position
* Check if a HTMLElement is hidden or fixed/sticky position
*/
*/
function
shouldSkipElement
(
element
:
HTMLElement
)
{
function
shouldSkipElement
(
element
:
HTMLElement
)
{
const
computedStyle
=
getComputedStyle
(
element
)
// we ignore fixed or sticky positioned elements since they'll likely pass the "in-viewport" check
// we ignore fixed or sticky positioned elements since they'll likely pass the "in-viewport" check
// and will result in a situation we bail on scroll because of something like a fixed nav,
// and will result in a situation we bail on scroll because of something like a fixed nav,
// even though the actual page content is offscreen
// even though the actual page content is offscreen
if
([
'sticky'
,
'fixed'
].
includes
(
computedStyle
.
position
))
{
if
([
'sticky'
,
'fixed'
].
includes
(
getComputedStyle
(
element
)
.
position
))
{
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
console
.
warn
(
console
.
warn
(
'Skipping auto-scroll behavior due to `position: sticky` or `position: fixed` on element:'
,
'Skipping auto-scroll behavior due to `position: sticky` or `position: fixed` on element:'
,
...
@@ -135,7 +133,11 @@ function shouldSkipElement(element: HTMLElement) {
...
@@ -135,7 +133,11 @@ function shouldSkipElement(element: HTMLElement) {
return
true
return
true
}
}
return
computedStyle
.
display
===
'none'
return
(
element
.
offsetParent
===
null
&&
element
.
tagName
!==
'HTML'
&&
element
.
tagName
!==
'BODY'
)
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment