javascript - Dragstart event not firing reactjs - Stack Overflow

dragstart event isn't firing on chrome browser...I want to set the state to true on mouse drag eve

dragstart event isn't firing on chrome browser...I want to set the state to true on mouse drag event. so i add the document.addeventlistener('dragstart', this.dragstart) to the mousedown method like below,

ponentDidMount() {
    document.addEventListener('mousedown', this.mousedown);
}

ponentWillUnMount() {
    document.addEventListener('mousedown', this.mousedown);
}

dragstart = () => {
   console.log("dragstart");
}

mousedown = e => {
    console.log("mousedown"); 
    document.addEventListener('dragstart', this.dragstart);
}

Could someone help me with this. Thanks.

dragstart event isn't firing on chrome browser...I want to set the state to true on mouse drag event. so i add the document.addeventlistener('dragstart', this.dragstart) to the mousedown method like below,

ponentDidMount() {
    document.addEventListener('mousedown', this.mousedown);
}

ponentWillUnMount() {
    document.addEventListener('mousedown', this.mousedown);
}

dragstart = () => {
   console.log("dragstart");
}

mousedown = e => {
    console.log("mousedown"); 
    document.addEventListener('dragstart', this.dragstart);
}

Could someone help me with this. Thanks.

Share Improve this question edited Mar 4, 2019 at 20:37 stackoverflow_user asked Mar 4, 2019 at 20:22 stackoverflow_userstackoverflow_user 2896 silver badges20 bronze badges 2
  • 1 What is render () { mousedown = e => {? It's not normal JSX construction. You should return ponents in render method – nucleartux Commented Mar 4, 2019 at 20:25
  • edited the question. had a typo – stackoverflow_user Commented Mar 4, 2019 at 20:29
Add a ment  | 

1 Answer 1

Reset to default 4

The ondragstart event occurs when the user starts to drag an element or text selection, but I don't think it will fire on a mousedown. As well, the element needs to be draggable.

<p draggable="true">

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745556269a4632839.html

相关推荐

  • javascript - Dragstart event not firing reactjs - Stack Overflow

    dragstart event isn't firing on chrome browser...I want to set the state to true on mouse drag eve

    20小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信