Video yükleniyor...

Video Yüklenemedi

Ana Sayfaya Dön

Little weekend prototype: iMessage style card stack. Always love a good reason to dive into Origami and work through visual + interactive puzzles like this. Here’s a bit about how I built it and a link to download ↓

166,430 görüntüleme • 2 yıl önce •via X (Twitter)

10 Yorum

Nate Smith profil fotoğrafı
Nate Smith2 yıl önce

The interactive layer and the visual layer are decoupled. There’s an invisible carousel of cards that you’re actually scrolling through. The visible stack of cards is entirely separate, animating independently based on scroll position.

Nate Smith profil fotoğrafı
Nate Smith2 yıl önce

In early versions, I focused on the transition from card 0 → 1. I could just “hard code” the transitioning values. This was an important step to figure out which properties to animate. You just couldn’t scroll past card 1 😅

Nate Smith profil fotoğrafı
Nate Smith2 yıl önce

When scrolling back from card 1 → 0, it just reversed the 0 → 1 animation. This made it feel like you’re grabbing a card behind the stack, pulling it to the front. What we really want is for it to feel like you’re always grabbing the front card and flicking it to either side.

Nate Smith profil fotoğrafı
Nate Smith2 yıl önce

So with all this, the real challenge was to figure out the dynamic logic needed to make this flexible and reusable. For this, I started to focus on the animations for card 2 instead of card 0.

Nate Smith profil fotoğrafı
Nate Smith2 yıl önce

All the logic is based on a progress value. When progress=0, card 0 is in the front; when progress=1, card 1 is in the front, etc. If we subtract the current progress from each card’s index, we get the distanceFromFront. We can use this to animate things like z-rotation.

Nate Smith profil fotoğrafı
Nate Smith2 yıl önce

Some things were more complicated. The toughest part was handling the animations of the front card and its 2 adjacent cards. As the distanceFromFront value goes from 1 to 0 to -1 to 0 to 1, we can perform a few functions to make it feel like you’re always grabbing the front card.

Nate Smith profil fotoğrafı
Nate Smith2 yıl önce

That’s pretty much it! Here it is with some photos from our recent trip to Japan. Satisfying to play with, super fun to build. If you wanna dive deeper, can download the file here:

Nate Smith profil fotoğrafı
Nate Smith2 yıl önce

Next, I’d like to replicate this in web with native CSS scroll snapping. It’d be amazing to also use CSS scroll-driven animations, but I’m not sure it would support this level of decoupling just yet (CC @bramus, @jh3yy 👀). Will play with a JavaScript solution for now..

Nate Smith profil fotoğrafı
Nate Smith2 yıl önce

I also wanna call out @RoberaGeleta and @daniel__designs for their takes on this interaction. Loved what Robera did with the y-rotation to fix the z-index jump.

Nate Smith profil fotoğrafı
Nate Smith2 yıl önce

made it so that you can drag in any direction. I’m sure this feels amazing, esp on a touchscreen. I pursued the decoupled carousel to figure out the logic needed for a native scroll gesture, e.g. trackpad swipe. We should compare notes!

Benzer Videolar

Introducing /visual-plan - a skill to generate rich, visual plans for Claude Code and Codex. Plan mode in Claude Code is incredible. But I always find my eyes glazing over when it gives me this huge markdown essay in my terminal. I found I can make much better visual plans with reusable components. So I made a skill called `/visual-plan`. It generates plans as MDX with visual, interactive components. Diagrams, interactive API specs, schema design changes, annotated code, and even pan and zoomable wireframes. So for any UI work, you can look at a wireframe first, comment on it, iterate, and then have the agent work. I’ve found this to be a much more intuitive interface for reasoning about what the agent is doing. It’s somewhat inspired by that popular post about how HTML is better than Markdown. But HTML can be slow and verbose to write. And it doesn’t look good checked into a repo. This has really made me feel like humans and engineering are entering a new abstraction phase, where we reason about things at the plan level. As long as the plan is good, agents are getting more and more reliable at executing on it. Almost to the degree that we trust the C compiler to compile to assembly reliably. Plans are the new intermediate representation. I also made a skill for the reverse of this, called `/visual-recap`. After the agent works, it gives you a recap of everything it did. Same idea: wireframes, interactive API specs and diffs, schemas, annotated code, etc. So now when you’re reviewing what the agent did for you, or looking at a pull request of somebody else’s code, you can see a visual recap instead of just reading a wall of text. It’s all free and open source. You can find it on my GitHub. Will link to it in the reply because we all know how dumb these algorithms are with links.

Steve (Builder.io)

123,036 görüntüleme • 22 gün önce