Check for SSR failure

This commit is contained in:
Moris Zen
2018-07-10 01:27:20 +02:00
parent 8ec8311204
commit 09f7b48064
2 changed files with 21 additions and 23889 deletions

View File

@@ -28,7 +28,9 @@ export function getSwipeDirection(x1, x2, y1, y2) {
}
export function isTouchDevice() {
return 'ontouchstart' in document.documentElement
if (typeof document !== 'undefined') {
return 'ontouchstart' in document.documentElement
}
}
export function sortNumber(a, b) {
@@ -36,9 +38,11 @@ export function sortNumber(a, b) {
}
export function getScreenWidth() {
return (
window.innerWidth ||
document.documentElement.clientWidth ||
document.body.clientWidth
)
if (typeof document !== 'undefined') {
return (
window.innerWidth ||
document.documentElement.clientWidth ||
document.body.clientWidth
)
}
}