我在屏幕的左側使用了Dojo Tree,在右側的列表中使用了Dragula(https://github.com/bevacqua/dragula)。這是非常簡單的,它的工作原理。
這裏有與Dragula列表對象的例子。
this.dnd = dragula([this.list], {
isContainer: function (el) {
return el.classList.contains('dijitTreeRow');
}
});
this.dnd.on('shadow', function (el, container, source) { // the event when yoi drag something tipo hover
// console.log(el, container);
var oldContainer; // change color of the drop item
oldContainer = query('.dndHover')[0];
if (oldContainer) {
domClass.remove(oldContainer, 'dndHover');
}
if (container === source) { // if drag and drop on the list do nothing
return;
}
domClass.add(container, 'dndHover'); // highlight current node
});
this.dnd.on('drop', function (el, container, source) { // drop event
var oldContainer; // remove highlight
oldContainer = query('.dndHover')[0];
if (oldContainer) {
domClass.remove(oldContainer, 'dndHover');
}
if (container !== source) {
// var widget = registry.getEnclosingWidget(el);
var target = registry.getEnclosingWidget(container);
// console.log(el, target);
// target = TREE NODE
// make your action (query, etc..)
}
}.bind(this));
CSS:
.dndHover{
background-color: #52D017 !important;
}
.dijitTreeRow .dragdiv {
display: none;
}
我會試試這個Stefano..Thx! – GoinOff