Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 30 additions & 38 deletions projects/ngx-panzoom/src/lib/panzoom.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,15 @@ export class PanZoomComponent implements OnInit, AfterViewInit, OnDestroy, PanZo
if (this.isMobile) {
this.frameElementRef().nativeElement.addEventListener('touchstart', this.onTouchStart);
}
else {
this.frameElementRef().nativeElement.addEventListener('mousedown', this.onMouseDown);
this.frameElementRef().nativeElement.addEventListener('dblclick', this.onDblClick );
this.frameElementRef().nativeElement.addEventListener(
'wheel',
(event: WheelEvent) => this.animationFrameFunc(
() => this.onMouseWheel(event)
),
{ passive: true }
);
}
this.frameElementRef().nativeElement.addEventListener('mousedown', this.onMouseDown);
this.frameElementRef().nativeElement.addEventListener('dblclick', this.onDblClick );
this.frameElementRef().nativeElement.addEventListener(
'wheel',
(event: WheelEvent) => this.animationFrameFunc(
() => this.onMouseWheel(event)
),
{ passive: true }
);

}
);
Expand All @@ -242,17 +240,15 @@ export class PanZoomComponent implements OnInit, AfterViewInit, OnDestroy, PanZo
if (this.isMobile) {
this.frameElementRef().nativeElement.removeEventListener('touchstart', this.onTouchStart);
}
else {
this.frameElementRef().nativeElement.removeEventListener('mousedown', this.onMouseDown);
this.frameElementRef().nativeElement.removeEventListener(
'wheel',
(event: WheelEvent) => this.animationFrameFunc(
() => this.onMouseWheel(event)
),
{ passive: true }
);
this.frameElementRef().nativeElement.removeEventListener('dblclick', this.onDblClick);
}
this.frameElementRef().nativeElement.removeEventListener('mousedown', this.onMouseDown);
this.frameElementRef().nativeElement.removeEventListener(
'wheel',
(event: WheelEvent) => this.animationFrameFunc(
() => this.onMouseWheel(event)
),
{ passive: true }
);
this.frameElementRef().nativeElement.removeEventListener('dblclick', this.onDblClick);
if (this.animationId) {
window.cancelAnimationFrame(this.animationId);
}
Expand Down Expand Up @@ -352,10 +348,8 @@ export class PanZoomComponent implements OnInit, AfterViewInit, OnDestroy, PanZo
document.addEventListener('touchend', this.onTouchEnd, false);
document.addEventListener('touchmove', this.onTouchMove, { passive: true, capture: false })
}
else {
document.addEventListener('mousemove', this.onMouseMove, { passive: true, capture: false });
document.addEventListener('mouseup', this.onMouseUp);
}
document.addEventListener('mousemove', this.onMouseMove, { passive: true, capture: false });
document.addEventListener('mouseup', this.onMouseUp);
}
); // leave this on document
}
Expand Down Expand Up @@ -562,18 +556,16 @@ export class PanZoomComponent implements OnInit, AfterViewInit, OnDestroy, PanZo
{ passive: true, capture: false } as EventListenerExtOptions
);
}
else {
document.removeEventListener(
'mousemove',
this.onMouseMove,
{ passive: true, capture: false } as EventListenerExtOptions
);
document.removeEventListener(
'mouseup',
this.onMouseUp,
{ passive: true } as EventListenerExtOptions
);
}
document.removeEventListener(
'mousemove',
this.onMouseMove,
{ passive: true, capture: false } as EventListenerExtOptions
);
document.removeEventListener(
'mouseup',
this.onMouseUp,
{ passive: true } as EventListenerExtOptions
);
}
);
// Set the overlay to non-blocking again:
Expand Down