-
Notifications
You must be signed in to change notification settings - Fork 396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
server-side rendering - window.addEventListener is not a function #49
Comments
I'm seeing this client-side when using parcel to bundle my app. I haven't done the steps to ensure this isn't just a parcel issue yet though. Anyone with a webpack/rollup build seeing this as well? |
I have the same issue as @aarongoin using classic vue app. I'm currently trying to do a little wrapper to make Zdog work in Vue environnement (someone is already doing the react one 😌 ) It's just a try for now. |
@aarongoin interesting, I am also using |
I'm having the same issue using |
Hey i had the same issue, i solved it by making the listener the canvas instead of the window. I'm not 100% sure yet if this has any unintended side effects. |
Yes this change has side effects with dragging, preventing movement and drag end event triggering unless the pointer is within the rendering element. |
I think this might be caused when dragger.js is being loaded as a commonjs module. Line 14 in 125bda0
this to be window , but for commonjs modules this will not be true.
If you are using webpack you can remedy this by using
Here are the webpack docs: https://webpack.js.org/guides/shimming/#granular-shimming |
I am having the same issue client-side, using webpack-dev-server. @statikowsky 's workaround seemed to fix the issue for me. |
Similar issue happening for me, I'm using import and babel in my build process. Zdog is rendering but, I'm getting this error when trying to drag:
|
I used the solution of @statikowsky with a I needed to add a // vue.config.js
module.exports = {
configureWebpack: {
module: {
rules: [
{
test: require.resolve('./node_modules/zdog/js/dragger.js'),
use: 'imports-loader?this=>window'
},
]
}
}
} I also use this library via |
Same issue with Parcel 😢 Code: import { Illustration, Shape } from 'zdog'
let illo = new Illustration({
element: '#app',
dragRotate: true,
})
new Shape({
addTo: illo,
path: [
{ x: -60, y: -60 }, // start
{ bezier: [
{ x: 20, y: -60 }, // start control point
{ x: 20, y: 60 }, // end control point
{ x: 60, y: 60 }, // end point
]},
],
closed: false,
stroke: 20,
color: '#636'
});
function animate() {
illo.updateRenderGraph()
requestAnimationFrame(animate)
}
animate() |
Is this not still fixed? :( I am facing the same issue. |
This works fine with Gatsby. Just install
|
Addresses `this = window` mismatch with Webpack, Parcel, Gatsby.
If you try to load Zdog in outside an browser-less environment like on server-side, you will likely run into an error
Zdog currently expects browser environment for things like
window
anddocument
. My basic recommendation is to add a conditional to disable loading Zdog on the server, and enable it for the browser. I'm not a server-side rendering expert, so any guidance here on how to manage would be appreciated.Add a 👍 reaction to this issue if you've ran into this issue so I know how prevalent this is.
The text was updated successfully, but these errors were encountered: