sachinchoolur / lightGallery

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

Error on destroying Lightgallery #1514

Closed guillermodelagala closed 1 year ago

guillermodelagala commented 1 year ago

Description

I have a SPA in which if I refresh it, the lightgallery in Angular SSR gives an error:

TypeError: Cannot read properties of undefined (reading 'destroy') at LightgalleryComponent.ngOnDestroy (C:\GIT\xxx\frontend\xxx\main.js:149677:13) at executeOnDestroys (C:\GIT\xxx\frontend\xxx\main.js:375290:20) at cleanUpView (C:\GIT\xxx\frontend\xxx\main.js:375204:5) at destroyViewTree (C:\GIT\xxx\frontend\xxx\main.js:375034:11) at destroyLView (C:\GIT\xxx\frontend\xxx\main.js:375182:5) at RootViewRef.destroy (C:\GIT\xxx\frontend\xxx\main.js:380895:5) at C:\GIT\xxx\frontend\xxx\main.js:394237:48 at Array.forEach (<anonymous>) at ApplicationRef.ngOnDestroy (C:\GIT\xxx\frontend\xxx\main.js:394237:27) at R3Injector.destroy (C:\GIT\xxx\frontend\xxx\main.js:377100:17)

Could you replace

ngOnDestroy(): void { this.LG.destroy(); this.lgInitialized = false; }

by

ngOnDestroy(): void { if (this.LG) { this.LG.destroy(); } this.lgInitialized = false; }

I have version 2.7.1 with Angular 15, but it also happens with 2.6.1

stale[bot] commented 1 year 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.

guillermodelagala commented 1 year ago

anyone?

RikudouSage commented 4 months ago

Did anyone manage to fix this?