Now, a lot of people critique this because the drawer, well, it's not as fancy, right? There are issues with the dialogue element. But there are additional CSS properties and features that come in here to save the day. For instance, starting style allows us now to just simply add animations to this thing using the straight up transition property. So now, again, you don't often think about, I mean, we think about these drawers as dialogues and drawers and whatever, but it's really simple to wire up a dialogue element, turn it into a drawer, and again, we get keyboard support, everything out of the box. And likewise, there's another property called a value, allow discrete, that you can set on properties that couldn't actually be animated in the past. So before you're trying to animate something out, use display none, it disappears from the DOM, there's no animation, now we have allow discrete, which allows you to essentially wait until the animation is completed before removing something from the DOM. So dialogue is great for these sort of reasons, and it does show Firefox support for this, and that's a bit wrong, because Firefox, where's my hover support? So Firefox, it has support for allow discrete, but not on display just yet. Hopefully very soon. I will say even with that, even with that allow discrete, that business, this does progressively enhance really well. Just by not having that on Firefox, you just don't get animation. That's not a problem. That's not a problem for me.
Alright. Scroll snap. Scroll snap is an API that has existed for a while now. It's available on a lot of browsers. Chrome 69 nice, Safari 11, Firefox 68, and a lot of people just think of scroll snap as being carousel sliders or whatever, but like the classic swipe real interface can be done so easily with like no code, with scroll swipe. And the thing I love about this is that, like, I know me personally, when I reach for touch animation libraries, drag animation libraries, whether that's motion or any of these things, they're great, they're fantastic, they allow you to do so many cool things, but nothing feels as stinkin' smooth as the scroll that's native into the browser. I don't, like, I've used a ton of scrolling and panning and whatever libraries, and they just don't feel as good as this. You're offloading a lot of that to JavaScript, you're just updating transition, or translation properties, when in this, it's just straight up scrolling. You get touch and scroll support without having to accommodate for either of that, and it just feels good. It's super easy. Scroll snap type, Y mandatory, overflow, auto. So I'm gonna go really quick through some of this stuff, because I gotta move here. This is the classic swiper. A lot of people don't think about this as you're always gonna reach for a component. I've reached for this a hundred times where you're doing the push down and drag events, and you're tracking the values, and you're doing the translation. This works with scroll snaps super easily. And the trick here is just that you're doing a grid, you have one in the middle that takes up the space, and you're snapping to the middle. So because you're always snapping to the middle, it can't ever reach the middle of the other one, so it just snaps back.
Comments