126 karma · joined May 10, 2022 (4y ago) · 36 submissions
comment 2y ago · link · parent
Updating the DOM (as in innerHTML) is always expensive because it triggers layout. This is true whether you're doing it from JS or a CSS trick like on this page.
Finally this approach is using CSS custom properties. These are slow - slower than JS for most things.
If you stop all animations on this page and profile it via Chrome you can see this in effect. The root node is animating a CSS variable. 117 elements have their style recalculated. Every frame - yet no animations are running. There's also a tiny paint triggered too, obviously there's been no changes so it is tiny in this instance, but a paint is always triggered when a CSS variable updates.
This is why animating x and y separately via CSS and a style like `translate(var(--x) var(--y))` would be worse than animating them via JS ala Framer Motion/GSAP.
comment 2y ago · link · parent
comment 2y ago · link · parent
This isn't even new. Casio etc have designed digital square watches for decades because they don't need to be round without clock arms.
comment 3y ago · link · parent
Look at your profiler. Notice any significant overhead? You don't.
Implement this same thing using events and `.style` directly. You will get the exact same result.
The pointerEvent => style feedback loop is unfortunately very slow, more or less so in different browsers/operating systems.
Interesting that you would know so little about this and yet feel confident enough to make a proclamation like this is evidence of React's performance.
comment 3y ago · link · parent
There is no "hold their own". This would be a state of perpetual warfare. The only way to end the war is to allow Russia to claim Ukraine or push Russia out of Ukraine. Personally I would rather the Russian border to be as far east as possible.
comment 3y ago · link · parent
The version in Framer has stuff like infinitely deep scale correction and shared element transitions so because of the filesize overhead (~10kb) I would only use this for complex stuff that is otherwise prohibitively tough (shared element transitions, layout etc).
However I do want to make the point that this approach should be more robust and simpler to maintain for even simple examples.
If you imagine an iOS-style pill toggle. The "simplest" way to animate this would be to have `translateX(0)` when off and something like `translateX(100px)` when on.
However, if there were no animations, this isn't how you'd write it. You'd probably do something like switch `flex-start` to `flex-end` on the parent.
This is easier to change the design and also maintain between breakpoints. But it can't be animated. Except with these technique, where you'd simply write
<motion.div layout />
And it would be. Much more maintainable.
comment 3y ago · link · parent
comment 3y ago · link · parent
To take border from your example, in the Framer app we add correction that fixes border. But border is tricky because it only renders rounded values and triggers layout - exactly what we're trying to avoid. I always recommend a two element approach, one with an inset. More performant and visually nicer.
We also use this API to do more advanced stuff like this <LayoutCamera /> component for React Three Fiber/Framer Motion 3D. https://www.framer.com/docs/layoutcamera/
This camera renders the scene pre-distorted so when the layout transform is applied, everything looks correct.
comment 4y ago · link · parent
Meh. I'm married, bought multiple houses, moved country. I don't know how many major life decisions you can make but none of them have changed me in the way merely expecting a child already has. I expect when they're born will reveal the next 90% of that transition.
comment 4y ago · link · parent
Maybe people in this thread are talking past each other but imo I agree with the commenter arguing that the image is ever "upside down", there is no image.