【发布时间】:2018-01-01 02:07:38
【问题描述】:
我正在尝试将在 https://github.com/bevacqua/dragula/issues/289#issuecomment-277143172 上找到的一些代码用于我的 Ionic 项目。
当我运行代码时,我收到一个错误Cannot find namespace 'NodeJS',该错误指的是touchTimeout: NodeJS.Timer;
如何修改下面的代码以使NodeJS.Timer 行工作?
import { Directive, ElementRef, HostListener } from '@angular/core';
@Directive({ selector: '[delayDragLift]' })
export class DelayDragLiftDirective {
dragDelay: number = 200; // milliseconds
draggable: boolean = false;
touchTimeout: NodeJS.Timer;
@HostListener('touchmove', ['$event'])
// @HostListener('mousemove', ['$event'])
onMove(e: Event) {
if (!this.draggable) {
e.stopPropagation();
clearTimeout(this.touchTimeout);
}
}
@HostListener('touchstart', ['$event'])
// @HostListener('mousedown', ['$event'])
onDown(e: Event) {
this.touchTimeout = setTimeout(() => {
this.draggable = true;
}, this.dragDelay);
}
@HostListener('touchend', ['$event'])
// @HostListener('mouseup', ['$event'])
onUp(e: Event) {
clearTimeout(this.touchTimeout);
this.draggable = false;
}
constructor(private el: ElementRef) {
}
}
【问题讨论】:
标签: angular ionic-framework ionic2