admin管理员组文章数量:1178545
<div className="kat-project-user-timeline-drag-indicator-wrapper-bottom"
onDrag={(event) => {this.dragTask(event)}}>
</div>
dragTask(event) {
console.log("logic goes here")
}
The function is not getting called for the first time. But from second time it is working fine. I tried using, event.preventDefault(), but still it is not working.
<div className="kat-project-user-timeline-drag-indicator-wrapper-bottom"
onDrag={(event) => {this.dragTask(event)}}>
</div>
dragTask(event) {
console.log("logic goes here")
}
The function is not getting called for the first time. But from second time it is working fine. I tried using, event.preventDefault(), but still it is not working.
Share Improve this question edited Jun 23, 2016 at 13:45 Nhan 3,8856 gold badges34 silver badges40 bronze badges asked Jun 23, 2016 at 12:54 Amala JamesAmala James 1,4863 gold badges17 silver badges33 bronze badges 4 |3 Answers
Reset to default 36Try adding draggable="true"
and see if that works:
<div draggable="true" className="kat-project-user-timeline-drag-indicator-wrapper-bottom"
onDrag={(event) => {this.dragTask(event)}}>
</div>
dragTask(event) {
console.log("logic goes here")
}
- Set the ondragstart event too, to the same function set to onDrag event
- set draggable="true".
Make the element draggable and Try onDragStart().
<div className="kat-project-user-timeline-drag-indicator-wrapper-bottom"
draggable={true} onDragStart={handleOnDrag}>
DRAGGABLE ELEMENT
</div>
本文标签: javascriptquotonDragquot event not getting triggered in reactjsStack Overflow
版权声明:本文标题:javascript - "onDrag" event not getting triggered in react.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1737997130a2046598.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
The function is not getting called for the first time
, do your logic do anything with a click? also, are you moving (dragging), or just pressing the div without moving mouse/finger? – Bonatti Commented Jun 23, 2016 at 13:47