Image viewer for Ionic 2+

作者: 与蟒唯舞 | 来源:发表于2018-02-27 18:37 被阅读61次

    Ionic 2+ component providing a Twitter inspired experience to visualize pictures.

    GitHub:https://github.com/Riron/ionic-img-viewer

    初始化项目
    ionic start myApp blank
    
    安装使用
    npm install --save ionic-img-viewer
    

    For Ionic 2 RC.0 and later:

    import { IonicImageViewerModule } from 'ionic-img-viewer';
    
    @NgModule({
      imports: [
        IonicImageViewerModule
      ]
    })
    export class AppModule {}
    

    home.html:

    <ion-header>
      <ion-navbar>
        <ion-title>Image Viewer</ion-title>
      </ion-navbar>
    </ion-header>
    
    <ion-content padding>
      <h1>Great and flexible image viewer for Ionic 2+</h1>
        <ul>
          <li>轻触图片可全屏查看</li>
          <li>手势上下滑动可关闭全屏查看</li>
          <li>点击导航箭头可关闭视图</li>
          <li>双击可放大</li>
        </ul>
          
        <h2>Code Trigger</h2>
        <img src="http://via.placeholder.com/150x150" #imageToView (click)="onClick(imageToView)">
        
        <h2>Images in a list</h2>
        <ion-list>
          <ion-item class="listItem" *ngFor="let item of items">
            <ion-thumbnail item-left>
              <img src="http://via.placeholder.com/300x300" imageViewer>
            </ion-thumbnail>
            <p>item {{ item }}</p>
          </ion-item>
        </ion-list>
    
    </ion-content>
    

    home.ts:

    import {
      Component
    } from '@angular/core';
    import {
      NavController
    } from 'ionic-angular';
    import {
      ImageViewerController
    } from "ionic-img-viewer";
    
    @Component({
      selector: 'page-home',
      templateUrl: 'home.html'
    })
    export class HomePage {
      items = [1, 2, 3];
      constructor(public navCtrl: NavController, public imageViewerCtrl: ImageViewerController) {}
    
      onClick(imageToView) {
        const viewer = this.imageViewerCtrl.create(imageToView)
        viewer.present();
      }
    
    }
    

    相关文章

      网友评论

      • e4e074a62da6:如何实现点击安卓的物理返回键来关闭这个放大得图片

      本文标题:Image viewer for Ionic 2+

      本文链接:https://www.haomeiwen.com/subject/ibbmxftx.html