vue-sticky icon indicating copy to clipboard operation
vue-sticky copied to clipboard

Use with Gridsome / SSR

Open davestewart opened this issue 4 years ago • 0 comments

Hello,

Gridsome bails when using this plugin, as window is not available:

ReferenceError: window is not defined
    at Object.<anonymous> (node_modules/vue-sticky/dist/vue-sticky.js:1:198)
    at __webpack_require__ (webpack/bootstrap:25:0)
    at Module.<anonymous> (assets/js/app.1a437b52.js:7771:18)
    at __webpack_require__ (webpack/bootstrap:25:0)
    at Module.<anonymous> (node_modules/gridsome/app/main.js:4:9)
    at __webpack_require__ (webpack/bootstrap:25:0)
    at Object.module.exports.module.exports (assets/js/app.1a437b52.js:2918:18)
    at __webpack_require__ (webpack/bootstrap:25:0)
    at assets/js/app.1a437b52.js:118:18
    at Object.<anonymous> (assets/js/app.1a437b52.js:121:10)

I tried the following, but no luck:

v-sticky="{ stickyTop: 40, disabled: process.isServer }"

I thought this would make it work, but it doesn't:

const unwatch = () => {
  window && window.removeEventListener('scroll', listenAction)
}
const watch = () => {
  window && window.addEventListener('scroll', listenAction)
}

Have you tested with SSR yet?

davestewart avatar Nov 12 '19 00:11 davestewart