答えて
私はイオンのフォーラムでこの回避策を見つけました:
HTML:
<ion-scroll (pinch)="pinchEvent($event)" scrollX="true" scrollY="true" zoom="true" style="width:100%;height:100%;text-align:center;">
<div [ngStyle]="{'background':'url('+src+') no-repeat','width' : width + 'px', 'height' : height + 'px', 'transform' : 'rotate('+rotacion+'deg)', 'background-size' : 'contain', 'background-position' : 'center'}" style="margin-top:50px;margin-bottom:50px;"></div>
</ion-scroll>
.TS方法:
pinchEvent(e) {
this.width = this.pinchW * e.scale;
this.height = this.pinchH * e.scale;
if(this.timeout == null){
this.timeout = setTimeout(() => {
this.timeout = null;
this.updateWidthHeightPinch();
}, 1000);
} else {
clearTimeout(this.timeout);
this.timeout = setTimeout(() => {
this.timeout = null;
this.updateWidthHeightPinch();
}, 1000);
}
}
updateWidthHeightPinch() {
this.pinchW = this.width;
this.pinchH = this.height;
}
Iコード "ピンチ" イベント自分自身を - それは非常に簡単でした(私は建物の床の地図をズームするためにそれを使用します):
div class="floor-map"
style="position: relative; left: 0px; top: 0px; height: 0px; overflow: hidden; cursor: move;"
(touchstart)="mapMoveStart($event)"
(touchend)="mapMoveStop($event)"
(touchmove)="mapMove($event)"
tappable
#floorMapRef
>
<img [style.width]="width + 'px'"
[style.height]="height + 'px'" ...>
</div>
そしてmapMoveで、私はこのようなものがあります:
pinchLenght = -1 // -1 means no pinch
...
mapMoveStart(event) {
this.pinchLenght = -1; // "reset" pinch
...
}
mapMove(event)
{
if(event.touches.length==2) { // two fingers detection
let length = Math.abs(event.touches[0].clientX-event.touches[1].clientX)
+ Math.abs(event.touches[0].clientY-event.touches[1].clientY);
if(this.pinchLenght < 0) { // case: first pinch "touch"
this.pinchLenght = length
} else {
let delta = length - this.pinchLenght;
this.pinchLenght = length;
if(delta>0) {
this.zoomMap(1.05);
}
if(delta<0) {
this.zoomMap(0.95);
}
}
}
...
}
...
そして方法zoomMap(zoomFactor: number)
に私はきちんと(<img>
タグに 'バインド' でした)this.height
とthis.width
を変更します。
is mapMoveStop )コードがありませんか? ...またはコールを削除する必要がありますか? – elingerojo
@elingerojo私は「アイデア」のみを表示します。私のコードはもっと複雑でした。私は、開始時と終了時にコード内のいくつかのものを初期化して初期化を解除しました。もしそれを行う必要があれば、mapMoveStartを満たし、mapMoveStop –
あなたは2+イオンのため
- インストール
NPM --saveイオン-IMG-ビューアをインストール
- を画像ビューアを使用することができるアプリに追加します。 module.ts
import { IonicImageViewerModule } from 'ionic-img-viewer'; @NgModule({ declarations: [ MyApp, HomePage ], imports: [ BrowserModule, IonicModule.forRoot(MyApp), IonicImageViewerModule ],
- プログラムによる使用:
<のIMG SRC = "IMAGE_URL" #myImage(クリック)= "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(); } }
- 1. 別のイメージでイメージをアンドロップできないようにする方法
- 2. のみchartjs-pluginのズーム範囲の間でズームできるようにする方法
- 3. イメージのサブビューをズームしないでイメージをズームするには?迅速なios
- 4. Googleマップのスクロールでのみズームできるようにする
- 5. uiimageview/uiscrollview(前後のズーム)でイメージを中央に配置する方法
- 6. イメージをボタンのように見えるようにする方法
- 7. イメージが常にロードされるようにする方法、ASP.NET
- 8. D3.jsでポリゴンをズームする方法
- 9. pyqtgraphでプロットをズームする方法
- 10. pdfファイルでWebViewをズームする方法
- 11. このリストアイテムを「ズーム」にする方法
- 12. 角2 - クラスをグローバルにアクセスできるようにする最良の方法
- 13. スクロールするときにズームする方法
- 14. CSSで2つのイメージをインラインに整列する方法
- 15. イメージにテキストを入力できるようにする
- 16. UIScrollViewでズームする方法は?
- 17. gvisGeoMap() - オンタリオにズームする方法
- 18. イメージを2つの異なるレイアウトに配置する方法
- 19. UIScrollViewをプログラムでズームする方法手動でズームする方法と全く同じ
- 20. このズーム機能とズーム機能を実現する方法
- 21. JComponentsをどのようにパンしてズームできますか?
- 22. ズームでテキストを選択できるようになっていますか?
- 23. OpenLayerマップをiphoneでどのようにズームするには?
- 24. wpf charting toolkitをどのようにズームすることができますか?
- 25. キャンバスの描画をズームする方法
- 26. HTML5 Canvas - ピクセルをズームする方法は?
- 27. UIScrollViewのコンテンツをどのようにズームするのですか
- 28. スタティックHTMLリソースからアクセスできるようにQtリソースにイメージをパックする方法
- 29. imagemagick(php api)で2つのイメージをマージする方法
- 30. ionicでイメージを圧縮する方法2
ありがとう、参考として、これは問題とフォーラムへのリンクです:https://forum.ionicframework.com/t/zoom-on-image-in-ionic-2/45910/13 – Noremac