dev-resources.site
for different kinds of informations.
Clip-Path Circle Reveal Animation With Mouse Movement
Published at
12/3/2024
Categories
javascript
webdev
gsap
animation
Author
plsankar
Author
8 person written this
plsankar
open
Whatโs the Plan?
Weโll create an animation where an image is revealed through a circle that moves with your mouse. Youโll also be able to tweak the size of the circle and experiment with the behavior.
Hereโs what youโll need:
- GSAP: For buttery-smooth animations.
- Tweakpane: For a slick UI to adjust the animation on the fly.
- HTML & CSS: To set up and style the page.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Clip-Path Animation</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<img
src="https://images.unsplash.com/photo-1696149328298-6e2f257bd45a?q=80&w=2104&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
alt="Clip-path animation">
<script src="script.js"></script>
</body>
</html>
CSS
body {
margin: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: #000;
overflow: hidden;
}
img {
width: 100%;
height: auto;
clip-path: circle(var(--size, 10%) at var(--x, 50%) var(--y, 50%));
transition: clip-path 0.6s;
}
JS
import gsap from "https://esm.sh/gsap";
// Smooth animations
const xTo = gsap.quickTo("img", "--x", { duration: 0.6, ease: "power3" });
const yTo = gsap.quickTo("img", "--y", { duration: 0.6, ease: "power3" });
const sizeTo = gsap.quickTo("img", "--size", { duration: 0.6, ease: "power3" });
// Update based on mouse movement
window.addEventListener("mousemove", (e) => {
xTo((e.clientX / window.innerWidth) * 100);
yTo((e.clientY / window.innerHeight) * 100);
});
Preview
gsap Article's
30 articles in total
How to improve the Frontend part of the project using one button as an example :))))
read article
Reflections on My Coding Journey: Lessons from Recent Weeks
read article
Circle Cursor Js #GSAP
read article
"Day 7 with GSAP: Interactive Scrolling Animation with Rotating Arrows"
read article
GSAP ScrollTrigger animation for Upwork Client Demo
read article
Day 6: Text Animation with GSAP โ A Split Letter Magic! ๐จโจ
read article
๐ Day 5: Creating a Hamburger Menu with GSAP
read article
Day 4: Enhancing UX with a Custom Cursor Using GSAP ๐๐จ
read article
"Unlocking the Power of GSAP for Stunning Web Animations" ๐จโจ
read article
Preloader Animation #GSAP
read article
GSAP: GreenSock Animation Platform ๐
read article
Animated Carousel
read article
๐ ๐ง๐ต๐ฒ๐ฅ๐ฒ๐ฎ๐น๐๐ผ๐๐ฒ๐น๐ ๐
read article
Clip-Path Circle Reveal Animation With Mouse Movement
currently reading
Getting started with Gsap!
read article
Todayโs new knowledge #7(GSAP)
read article
Image Reveal Animation with HTML, CSS, and GSAP
read article
Easy React Animation with GSAP
read article
MoonAlert A CSS Animated Moon Notification Box
read article
Creating a Mesmerizing Moonlit Night Sky Animation with CSS
read article
๐ Motion Scape With GSAP
read article
Pinning Images with GSAP: A Smooth Scrolling Animation in Next.js
read article
Learning GSAP with a Day-to-Night Scroll Animation ๐๐
read article
From Static to Stunning: Animate with GSAP
read article
Blurry Card with Parallax Effect ๐ณ
read article
Fun Animation using GSAP
read article
Future Bank Fintech Green: The Intersection of Finance and Sustainabilit
read article
Framer ground.
read article
Parallax image scroll speed with Nuxt 3 and GSAP ๐ฃ๏ธโจ
read article
Creating Interactive Hover Effects with GSAP and SplitType
read article
Featured ones: