3
我正在嘗試將我在https://github.com/bevacqua/dragula/issues/289#issuecomment-277143172上找到的一些代碼用於我的Ionic項目。當在Ionic 2中使用NodeJS.Timer時找不到名稱空間NodeJS
當我運行代碼我得到一個錯誤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) {
}
}
你解決了嗎? – Alberick0