Last active
May 5, 2019 13:55
-
-
Save tarun-dugar/7ed0983df9a55609525e19d845aaee4d 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
function smoothScroll(scrollParams) { | |
const elementToScroll = scrollParams.element; | |
const isWindow = elementToScroll === window; | |
const scrollDirectionProp = isWindow ? 'scrollX' : 'scrollLeft'; | |
const elementWidthProp = isWindow ? 'innerWidth' : 'clientWidth'; | |
const scrollLengthProp = 'scrollWidth'; | |
const initialScrollPosition = elementToScroll[scrollDirectionProp]; | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment