Created
July 18, 2017 22:07
-
-
Save rsms/3cdd2fa62973d1941101dc29802ce45f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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