-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(contextmenu): handle ios mobile device (#1119)
- Loading branch information
Showing
6 changed files
with
61 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './context-menu.directive'; | ||
export * from './long-press.directive'; |
30 changes: 30 additions & 0 deletions
30
packages/common/src/lib/context-menu/long-press.directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Directive, HostListener, Output, EventEmitter } from '@angular/core'; | ||
|
||
@Directive({ | ||
selector: '[igoLongPress]' | ||
}) | ||
export class LongPressDirective { | ||
private touchTimeout: any; | ||
@Output() longpress = new EventEmitter(); | ||
|
||
constructor() { } | ||
|
||
|
||
@HostListener('touchstart', ['$event']) | ||
public touchstart(e: TouchEvent) { | ||
this.touchTimeout = setTimeout(() => { | ||
this.longpress.emit(e); | ||
}, 400); | ||
} | ||
@HostListener('touchmove') | ||
@HostListener('touchcancel') | ||
@HostListener('touchend') | ||
public touchend() { | ||
this.touchEnd(); | ||
} | ||
|
||
|
||
private touchEnd() { | ||
clearTimeout(this.touchTimeout); | ||
} | ||
} |