From 235dbd9854e17b0872e7d89b96bee75c1114c8de Mon Sep 17 00:00:00 2001 From: Joshua Seigler Date: Tue, 10 Jun 2025 10:55:53 -0400 Subject: [PATCH] fix link-hover animation glitch --- site/_includes/base.njk | 44 +++++++++++++++++++++++-------------- site/_includes/css/site.css | 2 +- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/site/_includes/base.njk b/site/_includes/base.njk index eb628d1..07e877d 100644 --- a/site/_includes/base.njk +++ b/site/_includes/base.njk @@ -41,27 +41,37 @@ title: Joshua's Homepage document.addEventListener("scroll", setScrollAmount); document.addEventListener("resize", setScrollAmount); function rippleListener(el) { - return (evt) => { - const { - top, - right, - bottom, - left, - } = evt.target.getBoundingClientRect(); + return(evt) => { + const {top, right, bottom, left} = evt.target.getBoundingClientRect(); const effects = body.querySelector("#effects"); const newEffect = document.createElement("div"); newEffect.classList.add("effect-instance"); const padding = '10rem'; - newEffect.style.top = `calc(${top + window.scrollY}px - ${padding})`; - newEffect.style.left = `calc(${left + window.scrollX}px - ${padding})`; - newEffect.style.width = `calc(${right - left}px + 2 * ${padding})`; - newEffect.style.height = `calc(${bottom - top}px + 2 * ${padding})`; - newEffect.style.borderRadius = `${Math.min(bottom - top, right - left) / 2}px`; + newEffect.style.top = `calc(${ + top + window.scrollY + }px - ${padding})`; + newEffect.style.left = `calc(${ + left + window.scrollX + }px - ${padding})`; + newEffect.style.width = `calc(${ + right - left + }px + 2 * ${padding})`; + newEffect.style.height = `calc(${ + bottom - top + }px + 2 * ${padding})`; + newEffect.style.borderRadius = `${ + Math.min(bottom - top, right - left) / 2 + }px`; effects.appendChild(newEffect); const reverser = () => { newEffect.getAnimations().forEach(anim => { + if (anim.currentTime < 100) { + anim.pause(); + effects.removeChild(newEffect); + return; + } anim.pause(); - anim.updatePlaybackRate(5); + anim.updatePlaybackRate(1.5); anim.reverse(); anim.addEventListener('finish', () => { if (effects.contains(newEffect)) { @@ -69,14 +79,16 @@ title: Joshua's Homepage } }); }); - } + }; el.addEventListener('mouseleave', reverser); el.addEventListener('blur', reverser); } } - Array.from(document.querySelectorAll('a[href],.nav-toggle-button')).forEach(el => { + Array.from( + document.querySelectorAll('a[href],.nav-toggle-button,button,input[type="button"],input[type="submit"],input[type="reset"]') + ).forEach(el => { el.addEventListener('mouseenter', rippleListener(el)); el.addEventListener('focus', rippleListener(el)); }); - + \ No newline at end of file diff --git a/site/_includes/css/site.css b/site/_includes/css/site.css index df8234c..06d3486 100644 --- a/site/_includes/css/site.css +++ b/site/_includes/css/site.css @@ -643,5 +643,5 @@ body .isso-post-action { position: absolute; border-radius: 0.5rem; background: radial-gradient(ellipse farthest-side at 50% 50%, var(--c-accent) 25%, transparent); - animation: 5s ease normal forwards ripple; + animation: 10s ease-in normal forwards ripple; }