You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use Lightense on a page where some images are lazy loaded when a toggle is opened. I have a window.addEventListener('load' set up on the page generally, and am calling Lightense() on the images when they are loaded in.
The issue I'm seeing is that multiple instances of Lightense() break because the !d.querySelector('.lightense-backdrop') check causes config.container to be undefined:
Uncaught TypeError: Cannot read property 'removeEventListener' of undefined
at unbindEvents (lightense.js:366)
at removeViewer (lightense.js:299)
at init (lightense.js:337)
at HTMLImageElement.<anonymous> (lightense.js:193)
My solution is to set config.container to the already existing backdrop:
I'm trying to use Lightense on a page where some images are lazy loaded when a toggle is opened. I have a
window.addEventListener('load'
set up on the page generally, and am callingLightense()
on the images when they are loaded in.The issue I'm seeing is that multiple instances of
Lightense()
break because the!d.querySelector('.lightense-backdrop')
check causesconfig.container
to be undefined:My solution is to set
config.container
to the already existing backdrop:This fix works great, but I wanted to call it out and ask if there was a better solution to this general problem than what I'm doing. Thanks!
The text was updated successfully, but these errors were encountered: