Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ie11 MouseEvent condition #171

Merged
merged 2 commits into from
May 31, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion projects/angular2-draggable/src/lib/models/position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ export class Position implements IPosition {
constructor(public x: number, public y: number) { }

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

static isMouseEvent(e: MouseEvent | TouchEvent): e is MouseEvent {
return Object.prototype.toString.apply(e).indexOf('MouseEvent') === 8;
}

static isIPosition(obj): obj is IPosition {
return !!obj && ('x' in obj) && ('y' in obj);
}
Expand Down