From cb1d65e0b8c1882e52817905e4c83c8f0d554ca8 Mon Sep 17 00:00:00 2001 From: nicwands Date: Thu, 25 Jun 2026 13:55:47 -0400 Subject: [PATCH] color hover animation --- src/components/MosaicModal.vue | 6 ++--- src/components/MosaicViewport.vue | 37 ++++++++++++++++++++++++++++--- src/styles/_functions.scss | 5 +++++ src/styles/main.scss | 9 ++++++++ 4 files changed, 51 insertions(+), 6 deletions(-) diff --git a/src/components/MosaicModal.vue b/src/components/MosaicModal.vue index 726e39c..ce4ebb8 100644 --- a/src/components/MosaicModal.vue +++ b/src/components/MosaicModal.vue @@ -84,19 +84,19 @@ onMounted(() => { clipPath: 'inset(0% 0% 0% 0%)', ...ANIMATION_SETTINGS, }, - '<+0.1', + 0, ) tl.value.fromTo( contentWindow.value, { opacity: 0, clipPath: 'inset(0% 0% 100% 0%)' }, { opacity: 1, clipPath: 'inset(0% 0% 0% 0%)', ...ANIMATION_SETTINGS }, - '<+0.1', + 0, ) tl.value.fromTo( closeWindow.value, { opacity: 0 }, { opacity: 1, ...ANIMATION_SETTINGS }, - '<+0.1', + 0, ) tl.value.pause(0) diff --git a/src/components/MosaicViewport.vue b/src/components/MosaicViewport.vue index 1d33b63..6fe03a2 100644 --- a/src/components/MosaicViewport.vue +++ b/src/components/MosaicViewport.vue @@ -8,7 +8,7 @@ >
+
`hsl(${Math.random() * 360}deg ${THEME_S}% ${THEME_L}%)`, + ), +) + +const onMouseEnter = (i) => { + hoverColors.value[i] = + `hsl(${Math.random() * 360}deg ${THEME_S}% ${THEME_L}%)` +} const onIntersect = (isIntersecting) => { if (isIntersecting) { if (!cells.value) return const cellGifs = cells.value - .map((cell) => cell.$el?.children?.[0]) + .map((cell) => cell.$el?.children?.[1]) .filter(Boolean) gsap.to(cellGifs, { opacity: 1, duration: 0, stagger: 0.1 }) @@ -98,9 +113,25 @@ const onIntersect = (isIntersecting) => { aspect-ratio: 1; } } + .hover-bg { + position: absolute; + inset: 0; + clip-path: circle(0% at 50% 50%); + transition: clip-path 0.3s ease-in-out; + } .strapi-media { - mix-blend-mode: darken; opacity: 0; + position: relative; + z-index: 5; + } + + &:hover { + .strapi-media { + @include bonk-animation(0s, 1s, 10deg); + } + .hover-bg { + clip-path: circle(100% at 50% 50%); + } } } } diff --git a/src/styles/_functions.scss b/src/styles/_functions.scss index a7655fd..bf16763 100644 --- a/src/styles/_functions.scss +++ b/src/styles/_functions.scss @@ -185,3 +185,8 @@ $mobile-height: get('viewports.mobile.height'); } } } + +@mixin bonk-animation($delay: 0s, $duration: 1s, $angle: 25deg) { + --bonk-angle: #{$angle}; + animation: bonk $duration $delay infinite step-end; +} diff --git a/src/styles/main.scss b/src/styles/main.scss index b746203..1365017 100644 --- a/src/styles/main.scss +++ b/src/styles/main.scss @@ -59,3 +59,12 @@ dt { code { @include code; } + +@keyframes bonk { + 0% { + transform: rotate(calc(var(--bonk-angle) * -1)); + } + 50% { + transform: rotate(var(--bonk-angle)); + } +}