-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GSAP animation implemented on home page
- Loading branch information
1 parent
ad9065f
commit 477e211
Showing
14 changed files
with
119 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
{ | ||
"extends": "next/core-web-vitals", | ||
"rules": { | ||
"@next/next/no-img-element": "off" | ||
"@next/next/no-img-element": "off", | ||
"@react-hooks" : { | ||
"exhaustive-deps" : "off" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 10 additions & 2 deletions
12
frontend/src/components/pages/LandingPage/features/FeaturePage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
frontend/src/components/pages/LandingPage/pricing/PricingSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 10 additions & 2 deletions
12
frontend/src/components/pages/LandingPage/testimonials/TestimonialsSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 10 additions & 2 deletions
12
frontend/src/components/pages/LandingPage/works/HowItWorksSection .tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { gsap } from "gsap"; | ||
|
||
const useCardAnimation = () => { | ||
const handleUseCardAnimation = ( | ||
sectionRef: any, | ||
className: string, | ||
animationDirection: string = "bottom-to-top" | ||
) => { | ||
if (sectionRef.current) { | ||
const section = sectionRef.current; | ||
const handleScroll = () => { | ||
const sectionTop = section.getBoundingClientRect().top; | ||
const windowHeight = window.innerHeight; | ||
if (sectionTop < windowHeight / 2) { | ||
let animationProps: any = { | ||
opacity: 0, | ||
y: 100, | ||
duration: 1, | ||
stagger: 0.5, | ||
ease: "power4.out", | ||
}; | ||
|
||
switch (animationDirection) { | ||
case "top-to-bottom": | ||
animationProps.y = -100; | ||
break; | ||
case "left-to-right": | ||
animationProps.x = -100; | ||
break; | ||
case "right-to-left": | ||
animationProps.x = 100; | ||
break; | ||
default: | ||
"bottom-to-top"; | ||
animationProps.y = 100; | ||
break; | ||
} | ||
|
||
gsap.from(`.${className}`, animationProps); | ||
window.removeEventListener("scroll", handleScroll); | ||
} | ||
}; | ||
window.addEventListener("scroll", handleScroll); | ||
|
||
return () => { | ||
window.removeEventListener("scroll", handleScroll); | ||
}; | ||
} | ||
}; | ||
return handleUseCardAnimation; | ||
}; | ||
|
||
export default useCardAnimation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters