francoischalifour / medium-zoom

🔎🖼 A JavaScript library for zooming images like Medium
https://medium-zoom.francoischalifour.com
MIT License
3.58k stars 162 forks source link

Destroy/stop method #91

Closed chrisjansky closed 5 years ago

chrisjansky commented 5 years ago

Hello, nice work on this library! I am looking for a way to stop the plugin from firing more events right after opening the zoom window — I'll fade it out and destroy manually after a new page is loaded in the background.

Something like:

zoom.on('open', function() {
  zoom.off('open');
  }, {
  once: true
});

I tried detaching, but that "too cleverly" closes the modal before that, I really just want it to stop listening to any events (and stay opened).

Thanks.

francoischalifour commented 5 years ago

Can you please explain what feature you're trying to build (the why)? Checking if we can find a workaround with the current API.

chrisjansky commented 5 years ago

Here's a screencapture of what I needed to accomplish: https://www.dropbox.com/s/s4i4337kr6tv4pd/zoom-page-transition.mp4?dl=0

Basically use medium-zoom as a page transition, once the zoom is opened, destroy the instance and remove the HTML in a clean manner and show the new page that loaded beneath.

I ended up coding it myself, so you may close this issue if you think the API does not need change to allow things like this.

Thanks!

francoischalifour commented 5 years ago

I think this is outside of the scope of the library, so I'll close the issue.

Glad you found a way to achieve that with your own solution, it looks neat!