Fix flashing of no-src image when using next/image (#18195)

Solves on of the issues in https://github.com/vercel/next.js/issues/18122
This commit is contained in:
Tim Neutkens 2020-10-24 17:23:42 +02:00 committed by GitHub
parent 3c6f421d99
commit 58c161c99b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -64,6 +64,7 @@ function getObserver(): IntersectionObserver | undefined {
if (lazyImage.dataset.srcset) {
lazyImage.srcset = lazyImage.dataset.srcset
}
lazyImage.style.visibility = 'visible'
lazyImage.classList.remove('__lazy')
cachedObserver.unobserve(lazyImage)
}
@ -251,6 +252,7 @@ export default function Image({
paddingBottom: `${ratio}%`,
}
imgStyle = {
visibility: lazy ? 'hidden' : 'visible',
height: '100%',
left: '0',
position: 'absolute',