From 3ac57aebc30fa518cb891cb72c248e136cfa05ee Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Thu, 5 Dec 2024 05:09:05 +0000 Subject: [PATCH] style: format code with Prettier and StandardJS This commit fixes the style issues introduced in 8c67150 according to the output from Prettier and StandardJS. Details: None --- src/components/hooks/useInViewport/index.jsx | 62 ++++++------- .../stateless/AnimateOnScreen/index.jsx | 45 +++++++--- src/pages/home/index.jsx | 90 ++++++++----------- 3 files changed, 102 insertions(+), 95 deletions(-) diff --git a/src/components/hooks/useInViewport/index.jsx b/src/components/hooks/useInViewport/index.jsx index 931ddc92..bb4b9660 100644 --- a/src/components/hooks/useInViewport/index.jsx +++ b/src/components/hooks/useInViewport/index.jsx @@ -1,42 +1,44 @@ -import { useEffect, useRef, useState } from 'react'; - -const useInViewport = (triggerOnce = false, threshold = 0, rootMargin="0px" ) => { - const inViewRef = useRef(null); - const [inViewport, setInViewport] = useState(false); - const observer = useRef(null); +import { useEffect, useRef, useState } from 'react' +const useInViewport = (triggerOnce = false, threshold = 0, rootMargin = '0px') => { + const inViewRef = useRef(null) + const [inViewport, setInViewport] = useState(false) + const observer = useRef(null) useEffect(() => { - const targetElement = elementRef.current; - if (!targetElement) return; - observer.current = new IntersectionObserver((entries) => { + const targetElement = elementRef.current + if (!targetElement) return + observer.current = new IntersectionObserver( + (entries) => { entries.forEach((entry) => { - if (entry.isIntersecting && entry.intersectionRatio >= threshold) { - setInViewport(true); - if (triggerOnce) { - observer.current.disconnect() - } - } else { - setInViewport(false); + if (entry.isIntersecting && entry.intersectionRatio >= threshold) { + setInViewport(true) + if (triggerOnce) { + observer.current.disconnect() } - }); - }, {threshold, rootMargin}); + } else { + setInViewport(false) + } + }) + }, + { threshold, rootMargin } + ) if (inViewRef.current) { - observer.current.observe(inViewRef.current); + observer.current.observe(inViewRef.current) } return () => { - if (inViewRef.current) { - observer.current.unobserve(inViewRef.current); - } - }; - }, [threshold, triggerOnce, rootMargin]); + if (inViewRef.current) { + observer.current.unobserve(inViewRef.current) + } + } + }, [threshold, triggerOnce, rootMargin]) - return { - inViewRef, - inViewport - }; -}; + return { + inViewRef, + inViewport + } +} -export default useInViewport; +export default useInViewport diff --git a/src/components/stateless/AnimateOnScreen/index.jsx b/src/components/stateless/AnimateOnScreen/index.jsx index 18a7bc46..2cc2b948 100644 --- a/src/components/stateless/AnimateOnScreen/index.jsx +++ b/src/components/stateless/AnimateOnScreen/index.jsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useRef } from 'react' -const useElementOnScreen = (ref, rootMargin = '0px', threshold = 0, triggerOnce=false) => { +const useElementOnScreen = (ref, rootMargin = '0px', threshold = 0, triggerOnce = false) => { const [isIntersecting, setIsIntersecting] = useState(true) const observer = useRef(null) useEffect(() => { @@ -33,7 +33,7 @@ const AnimateIn = ({ from, to, rootMargin, threshold, triggerOnce, children }) = const ref = useRef(null) const onScreen = useElementOnScreen(ref, rootMargin, threshold, triggerOnce) const defaultStyles = { - transition: '1000ms ease-in-out', + transition: '1000ms ease-in-out' } return (
wave