When I close the fancybox the angular onDestroy method is called and the component is reinitializes from constructor to ngOnInit method.
Describe the bug
While closing the fancybox the onDestroy method of angual is called.
Reproduction
Open the fancybox with multiple images. Then close the modal. The ngOndestroy method is called.
Additional context
No response
Hi,
First, Fancybox is written in plain JS and works well when used with a wrapper for any JS framework like Angular, React, Vue, etc.
I think the Hash plugin might be causing you a problem, try disabling it (set Hash:false option), because it creates new history entry and then navigates back on closing.
Thanks for the reply, can you please tell me where to disable (set Hash:false option) in angular project.
It depends on how you use Fancybox, as I already explained, it is written in plain JS, so you most likely have some wrapper component, just find it and pass your custom options.
bindFancybox(inputEl: HTMLDivElement) { const options: any = { loop: true, buttons: ['close'], animationEffect: 'fade', Panzoom: { maxScale: 2, }, Hash: false, on: { destroy: () => { }, }, }; Fancybox.bind(inputEl, '[data-fancybox="gallery"]', options); }
You can use here. Thanks for the reply.