-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhance BackToTop to work in arbitrary scrollable containers [#150929…
…993] Signed-off-by: Ming Xiao <mxiao@pivotal.io>
- Loading branch information
Jonathan Berney
authored and
Ming Xiao
committed
Sep 12, 2017
1 parent
2be1f33
commit 28b3943
Showing
3 changed files
with
166 additions
and
95 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,3 @@ | ||
const isFirefox = () => navigator.userAgent.toLowerCase().indexOf('firefox') !== -1; | ||
|
||
const getScrollTop = () => isFirefox() ? document.documentElement.scrollTop : document.body.scrollTop; | ||
|
||
const setScrollTop = value => { | ||
document.body.scrollTop = value; | ||
document.documentElement.scrollTop = value; | ||
}; | ||
|
||
const getScrollTop = ({scrollTop}) => scrollTop; | ||
const setScrollTop = (value, element) => element.scrollTop = value; | ||
export default {getScrollTop, setScrollTop}; |