https://codesandbox.io/s/nostalgic-cherry-wwpzj?file=/src/in...
(I made the exact same thing last year as a joke for our team monitors)
https://codesandbox.io/s/nostalgic-cherry-wwpzj?file=/src/in...
(I made the exact same thing last year as a joke for our team monitors)
On a technical note, not that there’s much you can do about this, but because you’re reading clientWidth and clientHeight each frame, you’re forcing reflow. A performant implementation would probably require avoiding the DOM altogether within the draw loop, so that would mean using canvas/webgl.
For science, I went ahead and converted the code to ES3 and ran on the 10-year old first generation iPad (with setInterval) and it's still pretty smooth.
EDIT: I added a simple rate-limiting function :)
No wonder modern frontend is such a mess.
I beleieve you are quite competent in this, so for me it's just another illustration of how HTML/DOM ecosystem is broken in so many ways that it takes enormous effort to perform such a trivial task. Thank you and plase stop wasting your time on this)
> Thank you and please stop wasting your time on this
Haha. Thanks. I like these mini-challenges, helps me relax for a few minutes :)
I think adding `will-change: transform` might help a bit, to hint the user agent that you'll be animating transforms...