Skip to content

Instantly share code, notes, and snippets.

@navin-moorthy
Last active January 12, 2020 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save navin-moorthy/5d6ab0a9ded484981394a071c49c2cd9 to your computer and use it in GitHub Desktop.
Save navin-moorthy/5d6ab0a9ded484981394a071c49c2cd9 to your computer and use it in GitHub Desktop.
CloneCSS-GSAP Back Ease Circles
<svg class="animation" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 716 1008">
<g fill="none" fill-rule="evenodd">
<rect width="716" height="1008" fill="#A5B229" />
<g class="circles" fill="#8DC0AF" transform="translate(0 292)">
<circle cx="358" cy="358" r="358" style="mix-blend-mode:multiply" />
<circle cx="358" cy="358" r="304" style="mix-blend-mode:multiply" />
<circle cx="358" cy="358" r="258" style="mix-blend-mode:multiply" />
<circle cx="358" cy="358" r="220" style="mix-blend-mode:multiply" />
<circle cx="358" cy="358" r="187" style="mix-blend-mode:multiply" />
<circle cx="358" cy="358" r="159" style="mix-blend-mode:multiply" />
<circle cx="358" cy="358" r="135" style="mix-blend-mode:multiply" />
<circle cx="358" cy="358" r="116" style="mix-blend-mode:multiply" />
</g>
</g>
</svg>
<h1>Click to restart</h1>
{
"scripts": [
"https://cdnjs.cloudflare.com/ajax/libs/gsap/3.0.5/gsap.min.js"
],
"styles": []
}
console.clear();
const $ = document.querySelector.bind(document);
const animation = $(".animation");
let master = gsap.timeline({ delay: 0.5 });
animation.style.cursor = "pointer";
function animationCircles() {
let tl = gsap.timeline();
tl.from(".circles circle", {
y: 800,
ease: "expo",
duration: 4,
stagger: {
each: -0.15
}
}).from(
".circles circle",
{
scale: 0.85,
ease: "back(4)",
duration: 0.5,
transformOrigin: "center center",
stagger: {
each: -0.06,
repeat: -1,
yoyo: true
}
},
1
);
return tl;
}
function init() {
master.add(animationCircles());
animation.onclick = () => {
master.restart();
};
}
window.onload = () => {
init();
};
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
html,
body,
svg {
width: 100%;
height: 100%;
}
body {
margin: 0;
padding: 0;
background-color: #001823;
display: grid;
place-items: center;
}
h1 {
position: fixed;
top: 10px;
left: 50%;
transform: translateX(-50%);
color: white;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment