lucaspulliese / vue-cool-lightbox

Vue.js lightbox inspired by fancybox.
https://vue-cool-lightbox.lucaspulliese.com
340 stars 55 forks source link

Bugsnag: Cannot read property 'clientWidth' of undefined #96

Open blaaat opened 3 years ago

blaaat commented 3 years ago

I haven't been able to reproduce this, but my Bugsnag is full of this error. It appears to trigger twice when it triggers.

Triggered in: TypeError Cannot read property 'clientWidth' of undefined node_modules/vue-cool-lightbox/dist/vue-cool-lightbox.esm.js:1296:24 f.setLightboxInnerWidth node_modules/vue-cool-lightbox/dist/vue-cool-lightbox.esm.js:1302:11 f.xPositionOnResize

Only happens in mobile browsers.

antoHero commented 3 years ago

Hello, @blaaat were you able to solve this? I ran into the same issue

blaaat commented 3 years ago

Hello, @blaaat were you able to solve this? I ran into the same issue

No, you?

Edit:

This is how to reproduce:

@lucaspulliese maybe remove eventlistener in beforeDestroy as well?

Usateid commented 2 years ago

@blaaat It's because when you close the modal ( withouth using the X button ) the event window.removeEventListener('resize', this.xPositionOnResize) is not used. To solve this problem, it's necessary to call that removeEventListener when the modal is closed, in every way possible. Or call that function inside the beforeDestroy as you said, but it's necessary export that methods from the plugin

saibrok commented 1 year ago

if still relevant

beforeDestroy () {
  window.removeEventListener('resize', this.$refs.CoolLightBox.xPositionOnResize);
},