--- title: Drag outside tree js: examples/drag-outside.js ---

« Example 12 Example 14 »

Example 13 - drag node outside tree

drag here (see the console)

javascript

{% highlight js %} var targetCollisionDiv = $("#targetDiv"); function isOverTarget(e) { return ( e.clientX > targetCollisionDiv.position().left && e.clientX < targetCollisionDiv.position().left + targetCollisionDiv.width() && e.clientY > targetCollisionDiv.position().top && e.clientY < targetCollisionDiv.position().top + targetCollisionDiv.height() ); } function handleMove(node, e) { if (isOverTarget(e)) { console.log("the node is over the target div"); } } function handleStop(node, e) { console.log("stopped over target: ", isOverTarget(e)); } $('#tree1').tree({ onDragMove: handleMove, onDragStop: handleStop }); {% endhighlight %}