Won’t this only work for a single scroll point vs all others? Seems pointless to continually update the attribute instead of just adding a binary class.
The idea behind it is two-fold, one, you got the data, why not share it with CSS. Two, the JavaScript logic is as dumb as it gets, no knowledge of classes or naming or behavior that is attached. By keeping the JavaScript this basic it's less prone to errors or growth due to edge cases.
Won’t this only work for a single scroll point vs all others? Seems pointless to continually update the attribute instead of just adding a binary class.
The idea behind it is two-fold, one, you got the data, why not share it with CSS. Two, the JavaScript logic is as dumb as it gets, no knowledge of classes or naming or behavior that is attached. By keeping the JavaScript this basic it's less prone to errors or growth due to edge cases.
For non-binary situations:
dev.to/rikschennink/using-smart-cs...
I'm not saying one or the other is better, it is simply an interesting alternative approach.