WEBLEB
Inicio
Editora de código
Iniciar sesión
Pro
Español
English
Français
Español
Português
Deutsch
Italiano
हिंदी
HTML
CSS
JS
body { background: #ffffff; margin: 0; overflow: hidden; } figure { display: flex; align-items: center; justify-content: center; height: 100vh; width: 100vw; } svg { padding: 5vw; width: 90vw; } svg > * { fill: #1c1c1c; stroke: #1c1c1c; stroke-width: 0.85px; } @keyframes tip { 0%, 100% { opacity: 0; } 10%, 80% { opacity: 1; } }
const elements = document.querySelectorAll("svg > *"); gsap.set(elements, { x: () => gsap.utils.random(-500, 500), y: () => gsap.utils.random(-500, 500), rotation: () => gsap.utils.random(-720, 720), scale: 0, opacity: 0 }); const tl = gsap.timeline({ repeat: -1, repeatDelay: 0.65, yoyo: true }); tl.to(elements, { x: 0, y: 0, scale: 1, opacity: 1, rotation: 0, ease: "power4.inOut", stagger: 0.0125, duration: 0.75 }); const svg = document.querySelector("svg"); svg.addEventListener("mouseenter", () => tl.timeScale(0.15)); svg.addEventListener("mouseleave", () => tl.timeScale(1));
Validating your code, please wait...
HTML
CSS
JS
body { background: #ffffff; margin: 0; overflow: hidden; } figure { display: flex; align-items: center; justify-content: center; height: 100vh; width: 100vw; } svg { padding: 5vw; width: 90vw; } svg > * { fill: #1c1c1c; stroke: #1c1c1c; stroke-width: 0.85px; } @keyframes tip { 0%, 100% { opacity: 0; } 10%, 80% { opacity: 1; } }
const elements = document.querySelectorAll("svg > *"); gsap.set(elements, { x: () => gsap.utils.random(-500, 500), y: () => gsap.utils.random(-500, 500), rotation: () => gsap.utils.random(-720, 720), scale: 0, opacity: 0 }); const tl = gsap.timeline({ repeat: -1, repeatDelay: 0.65, yoyo: true }); tl.to(elements, { x: 0, y: 0, scale: 1, opacity: 1, rotation: 0, ease: "power4.inOut", stagger: 0.0125, duration: 0.75 }); const svg = document.querySelector("svg"); svg.addEventListener("mouseenter", () => tl.timeScale(0.15)); svg.addEventListener("mouseleave", () => tl.timeScale(1));