Skip to content

Instantly share code, notes, and snippets.

@rsms
Created July 18, 2017 22:07
Show Gist options
  • Select an option

  • Save rsms/3cdd2fa62973d1941101dc29802ce45f to your computer and use it in GitHub Desktop.

Select an option

Save rsms/3cdd2fa62973d1941101dc29802ce45f to your computer and use it in GitHub Desktop.
let hasSmoothScrollFeat = true
function scrollToSmootly(container: Element, x: number, y: number) {
if (hasSmoothScrollFeat) {
try {
container.scrollTo({behavior:"smooth", top:y, left:x})
return
} catch (_) {
hasSmoothScrollFeat = false
}
}
container.scrollTo(x, y)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment