The swiss army knife of lossless video/audio editing
Website: draw a feature icon again when its card comes back on screen, and when it's tapped
Claude5f67a73a82c3
diff --git a/website/src/pages/index.astro b/website/src/pages/index.astroindex 300be07e..07d8d542 100644--- a/website/src/pages/index.astro+++ b/website/src/pages/index.astro@@ -36,19 +36,26 @@ const description = 'LosslessCut - Official downloads - free or paid version. Ed<Home stars={stars} /><!-- is:inline: plain JS, not compiled by Vite, which would look for a tsconfig and find the app's (see tsconfig.json) --><script is:inline>- // On touch screens, draw each feature card's icon once when the card reaches the middle of the screen (.draw in home.css).- // (Scroll-driven CSS animations can't do this yet in all browsers, e.g. on iOS.) With a mouse, the icons draw on hover instead.+ // On touch screens, draw each feature card's icon when the card reaches the middle of the screen (.draw in home.css), again+ // after it has left the screen, and when it's tapped. (Scroll-driven CSS animations can't do this yet in all browsers, e.g.+ // on iOS.) With a mouse, the icons draw on hover instead.if (matchMedia('(hover: none) and (prefers-reduced-motion: no-preference)').matches && 'IntersectionObserver' in window) {- const observer = new IntersectionObserver((entries) => {- for (const { target, isIntersecting } of entries) {- if (isIntersecting) {- target.classList.add('draw');- observer.unobserve(target);- }- }+ const inMiddle = new IntersectionObserver((entries) => {+ for (const { target, isIntersecting } of entries) if (isIntersecting) target.classList.add('draw');}, { rootMargin: '-35% 0px -35% 0px' }); // the middle 30% of the screen+ const onScreen = new IntersectionObserver((entries) => {+ for (const { target, isIntersecting } of entries) if (!isIntersecting) target.classList.remove('draw');+ });document.querySelector('.feature-grid')?.classList.add('draw-on-scroll');- document.querySelectorAll('.feature-card').forEach((card) => observer.observe(card));+ document.querySelectorAll('.feature-card').forEach((card) => {+ inMiddle.observe(card);+ onScreen.observe(card);+ card.addEventListener('click', () => {+ card.classList.remove('draw');+ card.getBoundingClientRect(); // so that the animation starts over+ card.classList.add('draw');+ });+ });}</script></body>diff --git a/website/src/styles/home.css b/website/src/styles/home.cssindex ea6db199..50230341 100644--- a/website/src/styles/home.css+++ b/website/src/styles/home.css@@ -291,7 +291,7 @@ go into extra columns to the side, which Safari didn't lay out again when openedcolor: var(--accent);background-color: color-mix(in srgb, var(--accent) 13%, white);}-/* The icon draws itself: on hover (desktop), and on touch screens once, when the card reaches the middle of the screen (.draw,+/* The icon draws itself: on hover (desktop), and on touch screens when the card reaches the middle of the screen or is tapped (.draw,set by the script in index.astro, which first sets .draw-on-scroll to hide the icons until then). Every line of the icon has pathLength 1 (Home.tsx), so a dash of 1 (with a gap of 2,so that no dot of the next dash shows) draws each line from start to end in the same time. */@keyframes feature-icon-draw {