5 ms·
You can use the CSS attribute "scroll-behavior: smooth" which avoids the hazards of using JS to hijack the scroll event. I don't believe it works on safari, bu
by ficklepickle 6y ago
You can use the CSS attribute "scroll-behavior: smooth" which avoids the hazards of using JS to hijack the scroll event.
I don't believe it works on safari, but safari is the new IE so what can you do.
- pavlobu 6y agoI removed it and it really works ok now even with safari. Uh.. Honestly I did not write a full website and just grabbed the one I found on github. It is a cool template, though, it is not completely 'react' and still using some legacy JS libraries, even jQuery (!)
- vulcan01 6y agojQuery is legacy now? I still use it... Is it just not new enough?
- michaelpb 6y agoYes, and the main historical reasons people used jQuery was for smoothing over browser discrepancies and using CSS selectors in JS, but with IE9 we have `querySelectorAll` which made what was jQuery's biggest selling point for many, standard to vanilla JS. I also find it more confusing to teach to beginners than equivalent vanilla JS, and easier to make performance-hurting mistakes.
- tambourine_man 6y agojQuery’s API is still (and, probably, forever will be) miles ahead of the native DOM API. Cross browser compatibility was just one of the reasons the world fell in love with jQuery.
- michaelpb 6y agoPersonally, I find it miles behind the modern native DOM API, which is what I prefer now, but I guess to each their own! (And I'm not even against jQuery, I used it extensively mid-2000s-2010s, including on fairly large SPAs, and even taught a class with it for a little under 2 years, but again, to each their own)
- tambourine_man 6y agoIt's a lot more verbose and less powerful. I mean, the http://youmightnotneedjquery.com http://youmightnotneedjquery.com site reads like a parody even in 2021.
- michaelpb 6y agoI guess it truly does come down to preference and perception, as looking over that link you provided I actually had the opposite reaction! I prefer the DOM API in each example, save for examples that are clearly out of date to support old versions of IE without a polyfill (e.g. all the AJAX examples at the top can use fetch, other can use Object.assign, no use of the iterator interface anywhere, etc)
- tambourine_man 6y agoThis is something I really can't fathom. It takes twice as much typing without the chainable, unix pipe like API. I really don't get it, but I've been baffled by this industry's decision for more than a decade.
- resonious 6y agoVanilla JS works just as well now, so jQuery is just bloat.
- pavlobu 6y agoI mean there is no point to use jQuery if you use react. In that meaning jQuery is legacy. That is just my humble opinion.
- grishka 6y agoThe #1 problem with all these scripts is that they make the scrolling wonky when you use the trackpad on macOS. There's supposed to be a 1:1 relationship between how far you move your fingers and how far it scrolls, and these make it either fly off the screen at the speed of light or feel like you're scrolling through molasses. Either way, it clashes with your muscle memory.