Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rakeshbaral92 opened this issue Dec 17, 2024 · 4 comments
Labels
needs triage This issue has not been triaged by maintainers

Comments

@rakeshbaral92
Copy link

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 rakeshbaral92 added the needs triage This issue has not been triaged by maintainers label Dec 17, 2024
@rakeshbaral92 rakeshbaral92 changed the title When I close the lightbox the angular onDestroy method is called and the component is reinitialises from constructor to ngOninit method. When I close the fancybox the angular onDestroy method is called and the component is reinitializes from constructor to ngOnInit method. Dec 17, 2024
@fancyapps
Copy link
Owner

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.

@rakeshbaral92
Copy link
Author

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

@fancyapps
Copy link
Owner

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.

@rakeshbaral92
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been triaged by maintainers
Projects
None yet
Development

No branches or pull requests

2 participants