'Mapbox : is it possible to know if the popup has been closed manually?

I know there is a close event for the Mapbox popups.

popup.on('close',fn(e)=>{...})

This is fired any a popup closes, no matter how (automatically or manually).

Is there a way to detect if the user has closed the popup manually (by clicking the 'X' on the top right) ?

I need a different behaviour depending on how the popup was closed...

Thanks !



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source