Closed Berkmann18 closed 4 years ago
I have the same issue with ReferenceError: window is not defined
. Did you ever figure out what causes it?
@ukristen I did, and the solution was not using this particular library or vue-scrollmagic
but the vanilla ScrollMagic with:
My code had something like the below, which basically loaded the ScrollMagic library in the <head>
then used it in the mounted
hook.
<script>
export default {
name: 'products',
props: {
products: {
type: Array,
required: true
}
},
computed: {
extProducts() {
return [
{
name: 'Overview',
action: 'Overview',
type: '',
url: '#Overview',
image: ''
},
...this.products
];
}
},
methods: {
animate(ScrollMagic) {
const controller = new ScrollMagic.Controller();
const productHeight = parseFloat(
getComputedStyle(document.getElementById('products')).height
);
const rightHandHeight = 0.59727 * productHeight;
const rightScene = new ScrollMagic.Scene({
triggerElement: '#products',
duration: rightHandHeight
})
.setPin('#stackLayer')
.addTo(controller);
}
},
metaInfo: {
script: [
{
src: 'https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js',
async: true,
defer: true
}
]
},
mounted() {
if (process.isClient) {
setTimeout(() => this.animate(ScrollMagic), 500);
}
}
};
</script>
I'm not sure if this supports Gridsome or if I just set it improperly but I'm getting the following error in the devtools when running
gridsome develop
:Here's the relevant code: Products.vue
Also, I'm getting a
ReferenceError: window is not defined
error when tryinggridsome build
the site and I was wondering how I could go about it with this package.