diff --git a/client/components/LazyImage/index.js b/client/components/LazyImage/index.js index b6059cd..3ade7af 100644 --- a/client/components/LazyImage/index.js +++ b/client/components/LazyImage/index.js @@ -11,18 +11,18 @@ const optionsData = { const LazyImage = ({ alt, src, style, width, height }) => { const placeholder = `https://res.cloudinary.com/irfan-maulana-tkpd/image/fetch/c_fill,g_auto:face,h_50,fl_force_strip.progressive/f_webp/${encodeURIComponent( 'https://res.cloudinary.com/irfan-maulana-tkpd/image/upload/v1597041453/placeholder_qzxxc6.png', - )}`; + )}`; const [showSrc, setShowSrc] = useState(placeholder); const [loaded, setLoaded] = useState(false); const onIntersect = () => { - const imgObj = new Image(); - imgObj.onload = () => { - setLoaded(true); - } - imgObj.src = src; - setShowSrc(src); + const imgObj = new Image(); + imgObj.onload = () => { + setLoaded(true); + }; + imgObj.src = src; + setShowSrc(src); }; const targetRef = useIntersect(onIntersect, optionsData, true); diff --git a/client/styles/index.scss b/client/styles/index.scss index 97fddce..b9e2035 100644 --- a/client/styles/index.scss +++ b/client/styles/index.scss @@ -21,11 +21,13 @@ code { } .img { - transition: filter .5s linear; + transition: filter .5s linear; } + .img.img--loading { - filter: blur(1px); + filter: blur(1px); } + .img.img--loaded { - filter: blur(0); + filter: blur(0); }