summaryrefslogtreecommitdiff
path: root/client/src/useBlurryLoad.ts
diff options
context:
space:
mode:
authorMichael Hunteman <michael@huntm.net>2024-11-25 18:24:08 -0800
committerMichael Hunteman <michael@huntm.net>2024-11-25 18:24:08 -0800
commit2ccc9a5dcd85b616ed006ec88173ecc56e12c20e (patch)
tree872fb92493a3f20f29928fc9efaaf8a8195752d0 /client/src/useBlurryLoad.ts
parentea42387252c30a198f8f6251c5960f865e01b229 (diff)
Revert "Blurry load"
This reverts commit fab698d676d43a46b0fd5df592915ca12111dbcb.
Diffstat (limited to 'client/src/useBlurryLoad.ts')
-rw-r--r--client/src/useBlurryLoad.ts38
1 files changed, 0 insertions, 38 deletions
diff --git a/client/src/useBlurryLoad.ts b/client/src/useBlurryLoad.ts
deleted file mode 100644
index 59069d2..0000000
--- a/client/src/useBlurryLoad.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import { useEffect } from 'react';
-import './blurry-load.css';
-
-export interface UseBlurryLoadProps {
- toBlurImages?: Element[];
-}
-
-export const useBlurryLoad = (props?: UseBlurryLoadProps) => {
- const { toBlurImages = [] } = props ?? {};
-
- useEffect(() => {
- const images: Element[] = [...toBlurImages];
- if (toBlurImages.length === 0) {
- images.push(...document.querySelectorAll('.blurry-load'));
- }
-
- const lazyImageObserver = new IntersectionObserver(function (entries) {
- entries.forEach(function (entry) {
- if (!entry.isIntersecting) return;
-
- const image = entry.target;
- const currentImage = new Image();
- currentImage.setAttribute(
- 'src',
- image.getAttribute('data-large') ?? ''
- );
-
- currentImage.onload = () => {
- image.setAttribute('src', currentImage.src);
- image.classList.add('blur-out');
- };
- lazyImageObserver.unobserve(image);
- });
- });
-
- images.forEach((img) => lazyImageObserver.observe(img));
- }, [toBlurImages]);
-};