From 79db7e0971f57391fd96adb6e2e0930c1a021e23 Mon Sep 17 00:00:00 2001 From: wintsa Date: Wed, 30 Aug 2023 10:23:13 +0800 Subject: [PATCH] add nuxt3 --- dist/scrollreveal.js | 22 +++++++++++----------- src/instance/defaults.js | 2 +- src/instance/mount.js | 14 +++++++------- src/utils/get-scrolled.js | 2 +- src/utils/is-transform-supported.js | 2 +- src/utils/is-transition-supported.js | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/dist/scrollreveal.js b/dist/scrollreveal.js index 99b46d30..968f73ce 100644 --- a/dist/scrollreveal.js +++ b/dist/scrollreveal.js @@ -30,7 +30,7 @@ }, scale: 1, cleanup: false, - container: document.documentElement, + container: typeof document !=='undefined'? document.documentElement:'', desktop: true, mobile: true, reset: false, @@ -49,7 +49,7 @@ }; function failure() { - document.documentElement.classList.remove('sr'); + typeof document !=='undefined'?document.documentElement.classList.remove('sr'):''; return { clean: function clean() {}, @@ -63,12 +63,12 @@ } function success() { - document.documentElement.classList.add('sr'); + typeof document !=='undefined'?document.documentElement.classList.add('sr'):''; - if (document.body) { + if (typeof document !=='undefined'&&document.body) { document.body.style.height = '100%'; } else { - document.addEventListener('DOMContentLoaded', function () { + typeof document !=='undefined' && document.addEventListener('DOMContentLoaded', function () { document.body.style.height = '100%'; }); } @@ -517,7 +517,7 @@ var getPrefixedCssProp = (function () { var properties = {}; - var style = document.documentElement.style; + var style = typeof document !=='undefined'? document.documentElement.style:{}; function getPrefixedCssProperty(name, source) { if ( source === void 0 ) source = style; @@ -1317,10 +1317,10 @@ } })(); - var miniraf = window.requestAnimationFrame || + var miniraf = typeof window !=='undefined'? window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || - polyfill$1; + polyfill$1 :''; function getGeometry(target, isContainer) { /** @@ -1358,7 +1358,7 @@ function getScrolled(container) { var top, left; - if (container.node === document.documentElement) { + if (typeof document !=='undefined' &&container.node === document.documentElement) { top = window.pageYOffset; left = window.pageXOffset; } else { @@ -1452,12 +1452,12 @@ } function isTransformSupported() { - var style = document.documentElement.style; + var style =typeof document !=='undefined' ? document.documentElement.style:{}; return 'transform' in style || 'WebkitTransform' in style } function isTransitionSupported() { - var style = document.documentElement.style; + var style = typeof document !=='undefined' ? document.documentElement.style:{}; return 'transition' in style || 'WebkitTransition' in style } diff --git a/src/instance/defaults.js b/src/instance/defaults.js index f792196a..5ef1bb6e 100644 --- a/src/instance/defaults.js +++ b/src/instance/defaults.js @@ -13,7 +13,7 @@ export default { }, scale: 1, cleanup: false, - container: document.documentElement, + container: typeof document !=='undefined'?document.documentElement:{}, desktop: true, mobile: true, reset: false, diff --git a/src/instance/mount.js b/src/instance/mount.js index 69c84fe5..6e03b4cc 100644 --- a/src/instance/mount.js +++ b/src/instance/mount.js @@ -1,5 +1,5 @@ function failure() { - document.documentElement.classList.remove('sr') + typeof document !=='undefined'&&document.documentElement.classList.remove('sr') return { clean() {}, @@ -13,14 +13,14 @@ function failure() { } function success() { - document.documentElement.classList.add('sr') + typeof document !=='undefined'?document.documentElement.classList.add('sr'):''; - if (document.body) { - document.body.style.height = '100%' + if (typeof document !=='undefined'&&document.body) { + document.body.style.height = '100%'; } else { - document.addEventListener('DOMContentLoaded', () => { - document.body.style.height = '100%' - }) + typeof document !=='undefined' && document.addEventListener('DOMContentLoaded', function () { + document.body.style.height = '100%'; + }); } } diff --git a/src/utils/get-scrolled.js b/src/utils/get-scrolled.js index f284059c..64b7860d 100644 --- a/src/utils/get-scrolled.js +++ b/src/utils/get-scrolled.js @@ -1,6 +1,6 @@ export default function getScrolled(container) { let top, left - if (container.node === document.documentElement) { + if (typeof document !=='undefined' &&container.node === document.documentElement) { top = window.pageYOffset left = window.pageXOffset } else { diff --git a/src/utils/is-transform-supported.js b/src/utils/is-transform-supported.js index d15b86ce..f35af3c6 100644 --- a/src/utils/is-transform-supported.js +++ b/src/utils/is-transform-supported.js @@ -1,4 +1,4 @@ export default function isTransformSupported() { - const style = document.documentElement.style + const style = typeof document !=='undefined'?document.documentElement.style:{} return 'transform' in style || 'WebkitTransform' in style } diff --git a/src/utils/is-transition-supported.js b/src/utils/is-transition-supported.js index d15a23a9..dac20f53 100644 --- a/src/utils/is-transition-supported.js +++ b/src/utils/is-transition-supported.js @@ -1,4 +1,4 @@ export default function isTransitionSupported() { - const style = document.documentElement.style + const style =typeof document !=='undefined'? document.documentElement.style:{} return 'transition' in style || 'WebkitTransition' in style }