如何在Angular 2/4中发生mousedown事件后检测到鼠标仍然处于关闭状态

时间:2017-07-14 10:32:51

标签: angular mousedown

在mousedown事件被触发后,我想知道鼠标是否仍在某个元素上:

  activityIncrease(number){
      setTimeout(function () {
        mouseIsDown = I_NEED_SOMETHING_TO_TELL_ME_IF_THE_MOUSE_IS_STILL_DOWN();
        if(mouseIsDown) activityIncrease(number++);
      }, 100);
  }
<div *ngFor="let activity of group.activities" 
      class="col-xs-12 act" 
      (mousedown)="activityIncrease(activity.number)">
  <p>{{activity.description}}</p>
</div>

我该怎么做?

1 个答案:

答案 0 :(得分:0)

保留一个布尔变量mouseIsUp,如果mouseUpEvent被触发,则该变量为true,然后在timeoout函数中检查该变量