Skip to content

Commit 9583790

Browse files
authored
Merge pull request #171 from shumih/master
fix: ie11 MouseEvent condition
2 parents a7f05b7 + 3160a36 commit 9583790

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

projects/angular2-draggable/src/lib/models/position.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ export class Position implements IPosition {
77
constructor(public x: number, public y: number) { }
88

99
static fromEvent(e: MouseEvent | TouchEvent, el: any = null) {
10-
if (e instanceof MouseEvent) {
10+
/**
11+
* Fix issue: Resize doesn't work on Windows10 IE11 (and on some windows 7 IE11)
12+
* https://github.com/xieziyu/angular2-draggable/issues/164
13+
* e instanceof MouseEvent check returns false on IE11
14+
*/
15+
if (this.isMouseEvent(e)) {
1116
return new Position(e.clientX, e.clientY);
1217
} else {
1318
if (el === null || e.changedTouches.length === 1) {
@@ -26,6 +31,10 @@ export class Position implements IPosition {
2631
}
2732
}
2833

34+
static isMouseEvent(e: MouseEvent | TouchEvent): e is MouseEvent {
35+
return Object.prototype.toString.apply(e).indexOf('MouseEvent') === 8;
36+
}
37+
2938
static isIPosition(obj): obj is IPosition {
3039
return !!obj && ('x' in obj) && ('y' in obj);
3140
}

0 commit comments

Comments
 (0)