DEV Community

loading...

Discussion on: A JavaScript interview question asked at Facebook

Collapse
iaboelsuod profile image
Ibrahim Zahema

I think the challenge is asking if you know how to use requestanimationframe basically.

Collapse
stephenmirving profile image
Stephen Irving

But that is crazy overkill for this task. The appropriate way to implement this in current year is to use CSS. If an animation can be done without issue in CSS you should never use JS to do it. That is actually kind of a good rule to extrapolate and follow for everything on the front-end: Use JS only for the things you can't do with other technologies.

Collapse
elisabethgross profile image
Thread Thread
richardeschloss profile image
Richard Schloss

And, just a helpful link: Passing Parameters to CSS animation if anyone is interested... this would be the CSS way of doing it. JS events fire (like "scrolling", "mousemove") and the data from those events get passed to the css vars (but maybe someday we'd find it easier to pass an argument to a method in JS instead? easier to test maybe?). I think the webanimations API will surprise us all in [1-2 years?] and challenge us all as to what we do in JS vs CSS. I could be wrong. I'm still thinking about the pros and cons.