-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Cannot read properties of undefined (reading 'width') && undefined is not an object (evaluating 'this.containerRect.height') #1485
Comments
Thanks for the detailed information. |
Yes that's possible. |
@sachinchoolur Looks like the errors are related to the zoom plugin. After deactivating the plugin and deploying our new release, no more Sentry errors appeared. |
I'm getting similar errors in my logs. Looking quickly at the code of the zoom plugin, my guess is that some code reading |
Hey @felix-berlin and @stof , I tried reproducing the issue many times. But, no luck so far. I think the issue occurs when the app is re-rendering and doesn't affect the real users. Is it possible for you to use the un-minified version of the Zoom plugin for a few days? So that we'll get better stack traces |
@sachinchoolur Sentry is no longer tracking some of the issues. We will enable the zoom plugin again. When the errors appearing again, we will try to import the plugin unminified. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I was able to reproduce this issue on the Carousel gallery demo: https://www.lightgalleryjs.com/demos/carousel-gallery/ by clicking on the loader just before a picture is loaded |
We can also see in our error tracking that this issue is still present in v2.8.2. |
Description
Hi, we are using lightGallery in a larger project where we use Sentry for error logging. For some time now we have been receiving thousands of errors that seem to be related to lightGallery.
Unfortunately I have not been able to reproduce these errors myself. That's the reason why I created this issue.
In the following a few stack traces from Sentry:
Cannot read properties of undefined (reading 'getBoundingClientRect')
{snip} is.core.index).find(".lg-image").first().get(),i=0,r=0,s=n.getBoundingClientRect();t?(i=n.offsetHeight*t,r=n.offsetWidth*t):e?(i=s.height+e* {snip}
Cannot read properties of undefined (reading 'width')
{snip} ,e,n,i){if(!(Math.abs(e)<=0)){var r,s,o=this.containerRect.width/2+this.containerRect.left,a=this.containerRect.height/2+this.containerRect. {snip}
undefined is not an object (evaluating 'this.containerRect.height')
{snip} t,e,n,i){if(!(Math.abs(e)<=0)){var r,s,o=this.containerRect.width/2+this.containerRect.left,a=this.containerRect.height/2+this.containerRect {snip}
In the project we use Vue 2 + Laravel and lightGallery as a normal JS bundle.
Many thanks in advance!
Steps to reproduce
Unfortunately, I can't provide a demo, even though that would be much better to understand where the error might be.
JS code that you use to initialize lightGallery.
<!-- Bild-Slider in der Lightbox --> <template> <div class="m-lightbox"> <transition name="fade-fast"> <!-- Benachrichtigung, dass der Link der Produktdetailseite in die Zwischenablage kopiert wurde --> <div class="c-alert c-alert--success c-alert--success-buybox-image" v-if="this.showLinkCopiedTooltip"> {{ __('product_box.tooltips.copied') }} </div> </transition> </div> </template> <script> import lightGallery from 'lightgallery'; import 'lightgallery/css/lightgallery.css'; import 'lightgallery/css/lg-thumbnail.css'; import 'lightgallery/css/lg-video.css'; import 'lightgallery/css/lg-zoom.css'; import lgThumbnail from 'lightgallery/plugins/thumbnail'; import lgZoom from 'lightgallery/plugins/zoom'; import lgVideo from 'lightgallery/plugins/video'; export default { name: 'LightboxWrapper', props: { lightGallerySelector: { type: String, default: '#vendor-light-gallery', }, hasInfoText: { type: Boolean, default: false, }, }, data() { return { showLinkCopiedTooltip: false, lightGalleryDOMElement: null, currentImage: null, }; }, methods: { initLightGallery() { this.$callIfElementExists(this.lightGallerySelector, el => { // Docs: https://www.lightgalleryjs.com/docs/settings/ lightGallery(el, { plugins: [lgThumbnail, lgZoom, lgVideo], thumbnail: true, animateThumb: false, showThumbByDefault: false, licenseKey: process.env.MIX_LIGHT_GALLERY_KEY, speed: 500, download: false, // zeige keinem Download-Icon an autoplayFirstVideo: false, // starte Videos nicht automatisch strings: { previousSlide: this.__('slider.prev_button'), nextSlide: this.__('slider.next_button'), closeGallery: this.__('general.close'), playVideo: this.__('Play video'), }, mobileSettings: { controls: false, showCloseIcon: true, }, }); this.lightGalleryDOMElement = el; this.setUpLightGalleryEventListeners(); }); }, /** * Initialisiere Event Listeners für die Bilder im Gallery * */ setUpLightGalleryEventListeners() { // Nachdem ein Bild geladen wurde, erstelle auch einen Event-Listener fürs Bild, für das Öffnen vom Kontextmenü // Docs: https://www.lightgalleryjs.com/docs/events/#lgSlideItemLoad this.lightGalleryDOMElement.addEventListener('lgSlideItemLoad', event => { this.currentImage = document.querySelector(`#lg-item-1-${event.detail.index} img`); if (!this.currentImage) return; this.currentImage.addEventListener('contextmenu', this.imageEventListener); }); // Bevor das Gallery geschlossen wird, bzw. bevor ein Bild gewechselt wird, entferne den Event-Listener // Docs: https://www.lightgalleryjs.com/docs/events/#lgBeforeSlide this.lightGalleryDOMElement.addEventListener('lgBeforeSlide', this.removeImageEventListener); // Docs: https://www.lightgalleryjs.com/docs/events/#lgBeforeClose this.lightGalleryDOMElement.addEventListener('lgBeforeClose', this.removeImageEventListener); }, /** * Die Funktion die immer auf Rechtsklick vom Bild ausgeführt wird * */ imageEventListener(e) { e.preventDefault(); this.$copyProductLinkToClipBoard(); }, /** * Cleanup-Funktion für den Event-Listener * */ removeImageEventListener() { if (!this.currentImage) return; this.currentImage.removeEventListener('contextmenu', this.imageEventListener); this.currentImage = null; }, }, mounted() { this.initLightGallery(); }, }; </script>
Sample HTML markup
Environment
Cannot read properties of undefined (reading 'height')
Cannot read properties of undefined (reading 'width')
Additional context
The text was updated successfully, but these errors were encountered: