3 ms·
Performance. JS would need to run 60 times a second without hiccups. But JS is single-threaded, therefore any time something clogs your main thread you'll skip
by ckocagil 2y ago
Performance. JS would need to run 60 times a second without hiccups. But JS is single-threaded, therefore any time something clogs your main thread you'll skip a frame. Plus, as incredible as modern JS engines are they're still not as efficient as the native code, which leads to extra CPU usage and that spells trouble for battery life.
- ativzzz 2y agoThe way animations are done in react native for instance, is that you use JS to define the animation and send it to the native code which actually executes it. JS should just do the same in the browser instead of relying on an arcane language not designed for this
- Arisaka1 2y agoWhether a language is arcane or not depends on the levels of comfort one is familiar with the language, or how approximately familiar someone is with similar languages.
- ARCarr 2y agoGood news! You can with the Web Animations API.
- MisterKent 2y agoWhich are CSS animations underneath
- nfw2 2y agoYes, but you define them with Javascript rather than in CSS which is a key difference since the syntax is more intuitive for some (myself included)
- chefandy 2y agoSo since the original comment was questioning the necessity of animations in CSS, and JS is essentially using CSS animations for many things, I'd say the answer is yes. It's also a great way for UI designers to use subtle movement to hint at actions/status/next steps/etc without having to execute any JavaScript. When you've got a purely visual task, I'd say involving a general purpose programming tool is the unnecessary part— like using sed or the like vs opening up a repl in Python or whatever.
- ARCarr 2y agoShhh, don't tell him that.
- mattgperry 2y agoNo - CSS and JavaScript are two ways of defining the same thing, an animation. Safari runs its accelerated animations with CoreAnimation - is CoreAnimation a CSS animation?
- armandososa 2y agoJust recently I had to code a little but complex animation and I ended up using the web animations API. It's nice, it was a lot less code than the css counterpart. But, if I* have to write this same animation in two years and @property is widely available, I'll reach up for that first. *To be honest, it will be 100% an LLM that writes it for me.
- MisterKent 2y agoJS animation libraries let you declaratively define and hook into CSS animations. "Arcane language" not only is CSS one of the core languages of the web, but also if you find this arcane I wonder what you think of the "native" code that react native is generating for the animations. CSS as an animation engine is completely acceptable, and it's limitations (like the one in TFA) are slowly being pushed back.
- Jerrrrrrry 2y ago>"Arcane language" >"native" code that react native is generating for the animations. >CSS as an animation engine is completely acceptable, and it's limitation >TFA No way that pun is intended, but CSS is kinda a Tunable/Timed Finite Automaton; but being of a lower class of technically-capable expression than Javacscript, which is of a higher set of class of automata.
- taco_emoji 2y agoIt explicitly is designed for this, what are you talking about
- nitwit005 2y agoAlso just moving problems to the graphics card. The common rotate, transform, and so on, are all classic graphics hardware tasks.
- shepherdjerred 2y agoYou still need the CPU to tell the GPU what to do
- colordrops 2y agoRight, so you have simple statically defined optimized routines written in c/c++ calling the GPU, like any high performance graphics engine.