我正在成功添加" dragover "," dragleave "和" drop "来自" dragenter "的事件处理程序触发回调功能。
IE11不会添加树事件处理程序。 有什么建议?
// Drag-and-drop initiation.
if (!isMobile() && window.File && window.FileList && window.FileReader) {
// Declare global variables.
var dragStartsInside = false;
// Initialize scripts.
addEvent(window, "load", function () {
for (var e=0; e < elementsArray.length; e++) {
// Setup dnd listeners.
addEvent(elementsArray[e], "dragstart", function() {dragStartsInside = true; } );
addEvent(elementsArray[e], "dragenter", dragEnter);
addEvent(elementsArray[e], "dragend", function() {dragStartsInside = false; } );
}
});
// Drag and drop events.
function dragEnter(evt) {
cancelBubble(evt);
if (!dragStartsInside) {
// Add "dragStartsInside"-dependent events.
addEvent(evt.target, "dragover", dragOver);
addEvent(evt.target, "dragleave", dragLeave);
addEvent(evt.target, "drop", drop);
}
return cancelDefaultAction(evt);
}
function dragOver(evt) {
cancelBubble(evt);
...
return cancelDefaultAction(evt);
}
function drop(evt) {
cancelBubble(evt);
dragLeave(evt);
...
return cancelDefaultAction(evt);
}
function dragLeave(evt) {
removeEvent(evt.target, "dragover", dragOver);
removeEvent(evt.target, "dragleave", dragLeave);
removeEvent(evt.target, "drop", drop);
}
}