ui icon indicating copy to clipboard operation
ui copied to clipboard

When I close the fancybox the angular onDestroy method is called and the component is reinitializes from constructor to ngOnInit method.

Open rakeshbaral92 opened this issue 1 year ago • 4 comments

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

rakeshbaral92 avatar Dec 17 '24 09:12 rakeshbaral92

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.

fancyapps avatar Dec 17 '24 10:12 fancyapps

Thanks for the reply, can you please tell me where to disable (set Hash:false option) in angular project.

rakeshbaral92 avatar Dec 17 '24 10:12 rakeshbaral92

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.

fancyapps avatar Dec 17 '24 12:12 fancyapps

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.

rakeshbaral92 avatar Dec 17 '24 12:12 rakeshbaral92