Reputation: 289
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,
componentDidMount() {
document.addEventListener('mousedown', this.mousedown);
}
componentWillUnMount() {
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.
Upvotes: 1
Views: 6307
Reputation: 51
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">
Upvotes: 4