Club.noww.in
| I wanted a React lightbox where the photo grows out of the exact thumbnail you clicked and shrinks back into it on close. Easy, until your grid uses object-fit: cover. The thumbnail only shows the middle of the photo, so if you grow the full image from that box, the first frame visibly jumps. Here's the 4-step fix that worked: 1. Measure the end state first. Lay the image out at its final size, then measure it and the thumbnail with getBoundingClientRect(). 2. Scale it onto the thumbnail. Use the smallest uniform scale that still covers the thumb: const scale = Math.max(thumb.width / img.width, thumb.height / img.height); 3. Crop it like the thumbnail. clip-path: inset(...) hides everything the thumbnail hides. The catch: the inset is in the image's own pixels, before the scale, so the visible area is thumb size / scale. 4. Animate both at once. transform + clip-path in a single element.animate(). To close, play the same keyframes in reverse. That's the happy path. The edge cases ate most of the time:
Code: https://github.com/esdrassantos06/liftbox (the flight lives in src/Lightbox.tsx and src/geometry.ts) Docs + demos: https://liftbox.digital Two asks:
Disclosure: English isn't my first language, so I had help polishing this post. [link] [comments] |






![[Show /r/reactjs] veloce-ui — open-source React component library with 90+ components, 27 chart types, full CSS-variable theming](https://external-preview.redd.it/auBSaQn4CiBqrY0gtwtU2E_qU2OiXG3Nlkdead8_Src.png?width=640&crop=smart&auto=webp&s=90cbee1eceb5b560c2ba48f28bc3554e99f3844f)





English (US)