Comments (14)
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 imports-loader
.
The following webpack config worked for me:
module: {
rules: [
{
test: require.resolve('./node_modules/zdog/js/dragger.js'),
use: 'imports-loader?this=>window'
},
...
]
}
Here are the webpack docs: https://webpack.js.org/guides/shimming/#granular-shimming
A similar configuration should be possible for other bundlers.
from zdog.
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?
from zdog.
I'm having the same issue using parcel
.
Seems like an empty window
object is being used hence why addEventListener
is not available.
from zdog.
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.
from zdog.
I used the solution of @statikowsky with a vue ui
set up project.
I needed to add a vue.config.js
to the project root with this content
// 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 vue-zdog
wrapper and needed to install some more packages (and for some reason zdog too) via npm install --save import-loader vue-runtime-helpers zdog
it started to work.
from zdog.
In SHA: 3566dcb, I removed setting window
to this
and instead rely on global window
value, plus added some internal checks in case window
is undefined
. This fix is released in v1.1.1.
Please update and let me know of any lingering issues. Thanks all for your insights here.
from zdog.
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.
from zdog.
@aarongoin interesting, I am also using parcel
and having the same issue.
from zdog.
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.
from zdog.
I am having the same issue client-side, using webpack-dev-server. @statikowsky 's workaround seemed to fix the issue for me.
from zdog.
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:
TypeError: window.addEventListener is not a function
from zdog.
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()
from zdog.
Is this not still fixed? :( I am facing the same issue.
I am using parcel
to bundle. Eventually I want to use it on my Gatsby website. If it doesn't work with parcel
I doubt it will work with Gatsby.
from zdog.
Is this not still fixed? :( I am facing the same issue.
I am usingparcel
to bundle. Eventually I want to use it on my Gatsby website. If it doesn't work withparcel
I doubt it will work with Gatsby.
This works fine with Gatsby. Just install imports-loader
and then add this to your gatsby-node.js
exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
if (stage === 'build-html') {
actions.setWebpackConfig({
module: {
rules: [
{
test: require.resolve('./node_modules/zdog/js/dragger.js'),
use: loaders.null(),
},
],
},
})
} else {
actions.setWebpackConfig({
module: {
rules: [
{
test: require.resolve('./node_modules/zdog/js/dragger.js'),
use: 'imports-loader?this=>window',
},
],
},
})
}
}
- commenting for future reference and help with Gatsby.
from zdog.
Related Issues (20)
- Migrate codebase to ES8/TypeScript? HOT 8
- Element overlay late HOT 1
- Would wasm make it any faster? HOT 3
- 3D shape properties are not updated HOT 3
- Line across inside cylinder when fill is false HOT 2
- scene = new Zdog.Anchor() - Memory Leak? HOT 1
- why do shapes vanish when on a box HOT 1
- how animate a shape with a path HOT 1
- using for-loop and variables in path command HOT 1
- camera move(feature request) HOT 2
- Stroke Dasharray [feature request]
- Better documentation of normalizeRotate()
- Library
- how to import module of Zdog?
- Documentation website seems to be down
- Hollow Cone doesn't render in all rotations
- add light source
- [feature request] SVG lighting
- smoke effects cause model flickering HOT 3
- AddTo can't change after creation of Zdog element HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zdog.