| ▲ | jakelazaroff 10 hours ago |
| That is no longer true! You can do it in CSS with a combination of `@starting-style` and `transition-behavior: allow-discrete`. [1] Another gotcha you'll run into is animating the height. A couple other new features (`interpolate-size: allow-keywords` and `::details-content`) will let you get around that. [2] Modern CSS is awesome. [1] https://developer.chrome.com/blog/entry-exit-animations [2] https://nerdy.dev/open-and-close-transitions-for-the-details... |
|
| ▲ | port11 30 minutes ago | parent | next [-] |
| The major issue with this is that modern CSS is almost its own job, to the point we used to have Interface Developers at some place I’ve worked (HTML+CSS specialists). I did frontend for over a decade and eventually lost the train on CSS changes, I don’t even know what’s going on there anymore. It’s still awesome, but it’s becoming increasingly silly to ask someone to know modern HTML, CSS, JavaScript, Typescript, some build tools, a couple of frameworks, etc. The amount of JS we ship to clients is a reflection of cost-cutting measures at your workplace, not that every FE dev shuns CSS. |
|
| ▲ | wvenable 6 hours ago | parent | prev | next [-] |
| I can't see how a bunch of esoteric incantations are better than just some straight-forward easy to understand and follow JavaScript. |
| |
| ▲ | berkes 12 minutes ago | parent | next [-] | | Is that "straight-forward easy to understand and follow JavaScript" the whole thing written from scratch? Or does it use libraries (that use libraries, that use libraries)? Because I've written my share of javascript-from-scratch in my time - before npm and such. And even if my use-case was limited, in order to get edge-cases and details working - issues long solved by their HTML/CSS counterparts - we needed more and more JS. Many of which handwritten polyfills, agent-detection, etc. Seriously, things like scrollbars (because the client insisted on them being consistent across user-agents) or dropdowns (because they had to be styled) "visited" state on links, in pure JS are thousands of lines of code.
Maybe not today, anymore, IDK, with current APIs like the history API or aria labeling. But back then, just in order to make the dropdown work with screen readers, or the scrollbars react well to touchpads -in the direction the user was used to based on their OS- took us thousands of lines of JS, hacks, workarounds and very hard to follow code - because of the way the "solutions" were spread out over the exact right combination of JS, HTML and CSS. Edit: I now recall we got the web-app back with the comment "When I select "Language" and start typing "Fr" I expect French to be picked and "enter" to then put the language in French". We spent another few days on functions that collect character inputs in memory and then match them with values. All because "flags in front of the names were of crucial importance". So, maybe this is solved in modern HTML/CSS/JS. But I highly doubt it. I think "some straight-forward ... JavaScript" is either an `import { foo } from foobar` or a pipe-dream in the area of "programmers always underestimate hours" | |
| ▲ | yurishimo 6 hours ago | parent | prev | next [-] | | Because you need 20x the JS to do the same thing and it’s still not hardware accelerated. These new CSS properties are well supported and will only get better. | |
| ▲ | pikuseru 2 hours ago | parent | prev | next [-] | | Because a team of browser engineers have already written and reviewed the code to do it for you; and (hopefully) it’ll be performant, properly tested and accessible… ;-D | |
| ▲ | onion2k 3 hours ago | parent | prev | next [-] | | JS animations run on the main thread with everything else, so if your browser is busy doing something else the animation ends up being janky. Using CSS solves that problem. | |
| ▲ | dekoidal 2 hours ago | parent | prev | next [-] | | Is CSS too hard to learn or something? | |
| ▲ | paulddraper 4 hours ago | parent | prev [-] | | 1. CSS is declarative, so it avoid subtle bugs 2. CSS integrates better with HTML, as it has selectors to automatically bind to elements (yes there custom elements for JS) |
|
|
| ▲ | llmslave2 8 hours ago | parent | prev | next [-] |
| @starting-style Has less than 90% browser support making it a non-starter for the time being at least. |
| |
| ▲ | jakelazaroff 8 hours ago | parent | next [-] | | It'll just degrade gracefully into not animating the element's entry, so unless the animation is somehow crucial you should still be fine to use it. If you really need to detect whether it's supported there are hacky methods: https://www.bram.us/2024/07/11/feature-detect-css-starting-s... | | |
| ▲ | bryanrasmussen 4 hours ago | parent [-] | | I agree, but must also observe that I have never met a designer who was willing to admit without a knock-down drag-out fight that any animation they put in was not somehow crucial. | | |
| ▲ | mikedelfino 2 hours ago | parent | next [-] | | The trick is they'll see it working for themselves. :) | |
| ▲ | sfn42 an hour ago | parent | prev [-] | | I've never met a designer who wasn't completely fine with my suggestions for more pragmatic solutions. Like just styling a default scrollbar instead of implementing my own scrollbar to make it exactly like the design. Using a default drop-down menu instead of rolling my own just so I can round the corners of the selects. The designers I've worked with are fine with these things. We have more important things to work on than small style details. We can go back and change these things later if anyone actually cares, but generally nobody ever does. |
|
| |
| ▲ | paulddraper 4 hours ago | parent | prev [-] | | 91% of usage for browsers tracked by caniuse [1]. The biggest gap is Chrome versions > 2 years old. [1] https://caniuse.com/?search=%40starting-style |
|
|
| ▲ | RussianCow 6 hours ago | parent | prev [-] |
| You say awesome, I say layers upon layers of opaque incantations I have to remember. Thank god for LLMs. |
| |
| ▲ | pikuseru 2 hours ago | parent | next [-] | | “Layers upon layers of opaque incantations” You’ve described software. | |
| ▲ | sfn42 an hour ago | parent | prev | next [-] | | You're doing it wrong. You don't have to remember the incantations. You just have to remember that they exist, and then google them or ask an LLM when you need them. If you use something enough you'll remember. If you don't, you just look it up when you need it. This is basic programming, nobody remembers everything. | |
| ▲ | nchmy 5 hours ago | parent | prev [-] | | And how might you do this in Javascript? | | |
| ▲ | bryanrasmussen 4 hours ago | parent [-] | | they just said "LLMS"! | | |
| ▲ | nchmy 4 hours ago | parent [-] | | My point was that js would be vastly more complicated than these html/css "incantations". | | |
| ▲ | davidmurdoch 2 hours ago | parent [-] | | Most front end engineers could do it in JS without ever having to look something up. But the CSS to do it is still obscure to most. |
|
|
|
|