-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix scroll issue in search page (#86)
Signed-off-by: Cintia Sanchez Garcia <cynthiasg@icloud.com>
- Loading branch information
1 parent
4fe2372
commit 9449e90
Showing
5 changed files
with
61 additions
and
20 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const parser = require('ua-parser-js'); | ||
|
||
class BrowserDetect { | ||
private ua: any = {}; | ||
|
||
public init() { | ||
this.ua = parser(navigator.userAgent); | ||
} | ||
|
||
public isSafari(): boolean { | ||
if (this.ua.browser.name.includes('Safari')) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
} | ||
|
||
const browserDetect = new BrowserDetect(); | ||
browserDetect.init(); | ||
export default browserDetect; |
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,5 +1,12 @@ | ||
import browserDetect from './browserDetect'; | ||
|
||
const scrollToTop = (): void => { | ||
window.scrollTo(0, 0); | ||
const isSafari = browserDetect.isSafari(); | ||
window.scrollTo({ | ||
top: 0, | ||
// @ts-ignore: Unreachable code error | ||
behavior: isSafari ? 'instant' : 'auto', | ||
}); | ||
}; | ||
|
||
export default scrollToTop; |
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