Click event firing after dragging

后端 未结 2 1801
再見小時候
再見小時候 2021-01-24 05:21

Hey I\'m using Angular material Drag and drop. Everything is working fine but after each drag it triggers the click event and it\'s really annoying. How can I stop this?

2条回答
  •  春和景丽
    2021-01-24 05:30

    You can use a boolean to keep a track of this situation:

     var dragging = false;
     (cdkDragStarted): function(event, ui) {
        dragging = true;
        ...your code
     }
    
    (click): function(event) {
        if (!dragging) {
            ...your code
        }
        else {
            dragging = false;
        }
    });
    

提交回复
热议问题