-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added 'rootEl' oprional property to next/Image component resembling 'root' option of the Intersection Observer API * changed 'rootEl' to 'lazyBoundary' and its type as well * added test, fixed initial root detection * Update test/integration/image-component/default/test/index.test.js Co-authored-by: Steven <steven@ceriously.com> * prop names changed * added 'lazyroot' prop to the documentation * removed unused import * Apply suggestions from code review * Update docs with lazyRoot added in 12.0.9 Co-authored-by: Steven <steven@ceriously.com>
- Loading branch information
Showing
6 changed files
with
121 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
test/integration/image-component/default/pages/lazy-noref.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { useRef } from 'react' | ||
import Image from 'next/image' | ||
|
||
const Page = () => { | ||
const myRef = useRef(null) | ||
|
||
return ( | ||
<> | ||
<div | ||
ref={myRef} | ||
style={{ | ||
width: '100%', | ||
height: '400px', | ||
position: 'relative', | ||
overflowY: 'scroll', | ||
}} | ||
> | ||
<div style={{ width: '400px', height: '600px' }}>hello</div> | ||
<div style={{ width: '400px', position: 'relative', height: '600px' }}> | ||
<Image | ||
id="myImage" | ||
src="/test.jpg" | ||
width="400" | ||
height="400" | ||
lazyBoundary="1800px" | ||
/> | ||
</div> | ||
</div> | ||
</> | ||
) | ||
} | ||
export default Page |
33 changes: 33 additions & 0 deletions
33
test/integration/image-component/default/pages/lazy-withref.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { useRef } from 'react' | ||
import Image from 'next/image' | ||
|
||
const Page = () => { | ||
const myRef = useRef(null) | ||
|
||
return ( | ||
<> | ||
<div | ||
ref={myRef} | ||
style={{ | ||
width: '100%', | ||
height: '400px', | ||
position: 'relative', | ||
overflowY: 'scroll', | ||
}} | ||
> | ||
<div style={{ width: '400px', height: '600px' }}>hello</div> | ||
<div style={{ width: '400px', position: 'relative', height: '600px' }}> | ||
<Image | ||
lazyRoot={myRef} | ||
id="myImage" | ||
src="/test.jpg" | ||
width="400" | ||
height="400" | ||
lazyBoundary="1800px" | ||
/> | ||
</div> | ||
</div> | ||
</> | ||
) | ||
} | ||
export default Page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters