停止onDragLeave我目前的結構作出反應如何從擊發容器轉移到孩子時作出反應
var Component = React.createClass({
_testOver:function(){
console.log("Do action on hover");
},
_testOut: function(){
console.log("Do action on out");
},
render: function(){
return <div style={display:"none"}>
<div className="container"
onDragEnter={this._testOver}
onDragLeave={this._testOut}
style={{height:"400px",
paddingTop:"100px",
backgroundColor:"red"}}>
<div className= "child" style={{height:"200px",
backgroundColor:"blue"}}>
TESTING
</div>
</div>
</div>
}
});
當拖着東西在容器,_testOver()事件將觸發。 Hovever,當繼續拖動到孩子身上時,_testOut()事件將觸發,同時另一個_testOver()被觸發。
據我所知,它發生這樣的,因爲技術上鼠標拖出容器並進入孩子(這仍然是在容器內,因此發射另一個_testOver()事件)
我的問題是:當從父母移動到孩子(或孩子的孩子)時,有辦法阻止事件發生。即_testOver只會在我們將任何東西拖放到容器上時觸發,_testOut只會在我們將其拖出容器時觸發。 _testOut不應該從容器移動到兒童時觸發
謝謝!
如果沒有jquery,那將會非常好。 – modernator