sachinchoolur / lightGallery

A customizable, modular, responsive, lightbox gallery plugin.
https://www.lightgalleryjs.com/
Other
6.55k stars 1.29k forks source link

Cannot read properties of undefined (reading 'height') #1576

Closed vishal-ranjan-codes closed 8 months ago

vishal-ranjan-codes commented 10 months ago

Description

I am getting this error in my next.js 14 project -

Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading 'height')

Call Stack
Zoom.getDragAllowedAxises
node_modules\lightgallery\plugins\zoom\lg-zoom.es5.js (175:0)
HTMLDivElement.eval
node_modules\lightgallery\plugins\zoom\lg-zoom.es5.js (914:0)

Steps to reproduce

When I zoom-in by double-clicking a few times, I get this error.

JS code that you use to initialize lightGallery.

The component -

"use client";
import LightGallery from 'lightgallery/react';
import lgZoom from 'lightgallery/plugins/zoom';
import 'lightgallery/css/lightgallery.css';
import 'lightgallery/css/lg-zoom.css';
import 'lightgallery/css/lg-thumbnail.css';
import Image from "next/image";

interface LightBoxImageProps {
    className: string;
    src: string;
    alt: string;
    width: number;
    height: number;
}

const LightBoxImage: React.FC<LightBoxImageProps> = ({ className, src, alt, width, height }) => {
  return (
    <LightGallery speed={500} plugins={[lgZoom]} >
        <a className="cursor-zoom-in" href={src}>
            <Image className={className} src={src} alt={alt} width={width} height={height}/>
        </a>
    </LightGallery>
  )
}

export default LightBoxImage

Sample HTML markup

<div className="project-media-block">
  <LightBoxImage className="theme-br-b" src={'/Localizer - Information Architecture.webp'} alt="Localizer Journey Mapping" width={1400} height={1120}/>
</div>

Environment

stale[bot] commented 8 months ago

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.

zemkogabor commented 3 months ago

The problem still exists if I try to close gallery (with ESC key) when zoom is processing: Version: 2.8.0-beta.2

Screenshot from 2024-08-02 13-27-35 Screenshot from 2024-08-02 13-27-23