Skip to content

Commit 15814f1

Browse files
committed
WIP
1 parent 4a02193 commit 15814f1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/image-viewer-gesture.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ export class ImageViewerGesture extends PanGesture {
3939
}
4040

4141
canStart(ev: any): boolean {
42-
// If we are zoomed in || pinching (2 simultaneous touches at least)
43-
return !this.component.isZoomed && ev.touches.length < 2;
42+
const isPinching = ev.touches && ev.touches.length > 1;
43+
44+
return !this.component.isZoomed && !isPinching;
4445
}
4546

4647
onDragMove(ev: any): boolean {

src/image-viewer.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
Config,
1111
Platform
1212
} from 'ionic-angular';
13-
import { ElementRef, Renderer, Component, OnInit, OnDestroy, NgZone, ViewChild } from '@angular/core';
13+
import { ElementRef, Renderer, Component, OnInit, OnDestroy, AfterViewInit, NgZone, ViewChild } from '@angular/core';
1414
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
1515

1616
import { ImageViewerGesture } from './image-viewer-gesture';
@@ -36,7 +36,7 @@ const MAX_SCALE = 2;
3636
</div>
3737
`
3838
})
39-
export class ImageViewerComponent extends Ion implements OnInit, OnDestroy {
39+
export class ImageViewerComponent extends Ion implements OnInit, OnDestroy, AfterViewInit {
4040
public imageUrl: SafeUrl;
4141

4242
private dragGesture: PanGesture;
@@ -75,7 +75,7 @@ export class ImageViewerComponent extends Ion implements OnInit, OnDestroy {
7575
this._zone.runOutsideAngular(() => {
7676
this.pinchGesture = new Gesture(this.imageContainer.nativeElement);
7777
this.pinchGesture.listen();
78-
this.pinchGesture.on('pinch', this.onPinch);
78+
this.pinchGesture.on('pinch', (e) => this.onPinch(e));
7979
});
8080
}
8181

0 commit comments

Comments
 (0)