Image tags are fucked for right now.

Cart is working
This commit is contained in:
2024-10-08 10:05:58 +05:30
parent 990e7ee75b
commit 4df566df5e
47 changed files with 1113 additions and 1204 deletions

View File

@ -10,10 +10,7 @@ class IntersectionObserverManager {
constructor(options: IntersectionObserverInit) {
this.callbacks = new Map();
this.observer = new IntersectionObserver(
this.handleIntersect.bind(this),
options,
);
this.observer = new IntersectionObserver(this.handleIntersect.bind(this), options);
}
private handleIntersect(entries: IntersectionObserverEntry[]) {

View File

@ -8,9 +8,7 @@ interface UseInViewOptions extends IntersectionObserverInit {
triggerOnce?: boolean;
}
const useInView = (
options: UseInViewOptions,
): [RefObject<HTMLImageElement>, boolean] => {
const useInView = (options: UseInViewOptions): [RefObject<HTMLImageElement>, boolean] => {
const [isInView, setIsInView] = useState<boolean>(false);
const elementRef = useRef<HTMLImageElement>(null);
const observerManager = useSharedIntersectionObserver(options);
@ -18,9 +16,7 @@ const useInView = (
const element = elementRef.current;
if (!element) return;
const prefersReducedMotion = window.matchMedia(
'(prefers-reduced-motion: reduce)',
);
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
if (prefersReducedMotion.matches) {
setIsInView(true);
if (options.triggerOnce) {

View File

@ -19,18 +19,14 @@ const useInView = (
: Array.isArray(threshold) && threshold.every((t) => t >= 0 && t <= 1);
if (!isValidThreshold) {
console.warn(
'Invalid threshold value passed to useInView. It should be between 0 and 1.',
);
console.warn('Invalid threshold value passed to useInView. It should be between 0 and 1.');
}
useEffect(() => {
const element = ref.current;
if (!element) return;
const prefersReducedMotion = window.matchMedia(
'(prefers-reduced-motion: reduce)',
);
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
if (prefersReducedMotion.matches) {
setIsVisible(true);
return;