I've got a page with one single image, how can I make this image zoomable?
My Page
<div id="myresult" class="img-zoom-result"></div>
add the image to app directory scr/assets/img/Test. jpg.
With Ionic 4 the old ion-scroll is gone and with it the way we created a zoomable view. The good news is the Slides are still there and we can use them to create great effects and zooming inside our Ionic 4 app! In the past we have used packages that allowed us to zoom in or a general package to create an image gallery.
If you have specific requirements, there might not be an out of the box solution that works fine for you, that’s why we will create our own Ionic image gallery. We will display images in a gallery like infinite loop where we can always see the end of the previous image and the start of the following.
Additional, if you want image zooming inside your standard gallery view, your head might explode without the proper knowledge. Let me present you an easy way how to show an image gallery like in the Facebook app, with additional image zooming functionality for every picture while staying inside your carousel!
With Ionic 4 the old ion-scroll is gone and with it the way we created a zoomable view. The good news is the Slides are still there and we can use them to create great effects and zooming inside our Ionic 4 app!
You can use Image viewer for Ionic 2+
npm install --save ionic-img-viewer
import { IonicImageViewerModule } from 'ionic-img-viewer'; @NgModule({ declarations: [ MyApp, HomePage ], imports: [ BrowserModule, IonicModule.forRoot(MyApp), IonicImageViewerModule ],
< img src="IMAGE_URL" #myImage (click)="presentImage(myImage)" />
import { ImageViewerController } from 'ionic-img-viewer'; export class MyPage { _imageViewerCtrl: ImageViewerController; constructor(imageViewerCtrl: ImageViewerController) { this._imageViewerCtrl = imageViewerCtrl; } presentImage(myImage) { const imageViewer = this._imageViewerCtrl.create(myImage); imageViewer.present(); } }
DEMO : Demo ionic-img-viewer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With