Riron / ionic-img-viewer

Ionic 2+ component providing a Twitter inspired experience to visualize pictures.
MIT License
283 stars 118 forks source link

Close img-viewer in typescript #102

Closed InesBensalah closed 7 years ago

InesBensalah commented 7 years ago

Hi,

I want to check if the viewer is open and if is true close it in the typescript file for that I try to use :

<img src="IMAGE_URL" imageViewer (close)="callbackAfterImageViewerCloses()" />

But I don't know how to use it, can I have some help please.

Riron commented 7 years ago

The close event is a callback. It is called when the viewer is closed, not the other way around.

To manually close the viewer you have an exemple in the doc. You'll need to go for programmatic usage:

presentImage(myImage) {
  const imageViewer = this._imageViewerCtrl.create(myImage);
  imageViewer.present();

  setTimeout(() => imageViewer.dismiss(), 1000); // Here you see a call to the dismiss method, that closes the viewer
}