I have a strange issue which I can only replicate on Microsoft browsers (Edge and IE11 tested).
You can detect support for the behavior
option in scrollTo
using this snippet:
function testSupportsSmoothScroll () {
var supports = false
try {
var div = document.createElement('div')
div.scrollTo({
top: 0,
get behavior () {
supports = true
return 'smooth'
}
})
} catch (err) {}
return supports
}
Tested in Chrome, Firefox, Safari, and Edge, and seems to work correctly. If supports
is false, you fall back to a polyfill.