mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-23 06:20:01 +00:00
Fix problem with tracking dragenter/leave events in Firefox
Fixes #686 (hopefully!)
This commit is contained in:
parent
d778bc9a21
commit
39cdaeb34d
@ -50,32 +50,35 @@ DropZoneWidget.prototype.render = function(parent,nextSibling) {
|
||||
parent.insertBefore(domNode,nextSibling);
|
||||
this.renderChildren(domNode,null);
|
||||
this.domNodes.push(domNode);
|
||||
// Stack of outstanding enter/leave events
|
||||
this.currentlyEntered = [];
|
||||
};
|
||||
|
||||
DropZoneWidget.prototype.enterDrag = function() {
|
||||
// Check for this window being the source of the drag
|
||||
if($tw.dragInProgress) {
|
||||
return false;
|
||||
DropZoneWidget.prototype.enterDrag = function(event) {
|
||||
if(this.currentlyEntered.indexOf(event.target) === -1) {
|
||||
this.currentlyEntered.push(event.target);
|
||||
}
|
||||
// We count enter/leave events
|
||||
this.dragEnterCount = (this.dragEnterCount || 0) + 1;
|
||||
// If we're entering for the first time we need to apply highlighting
|
||||
if(this.dragEnterCount === 1) {
|
||||
$tw.utils.addClass(this.domNodes[0],"tc-dragover");
|
||||
}
|
||||
$tw.utils.addClass(this.domNodes[0],"tc-dragover");
|
||||
};
|
||||
|
||||
DropZoneWidget.prototype.leaveDrag = function() {
|
||||
// Reduce the enter count
|
||||
this.dragEnterCount = (this.dragEnterCount || 0) - 1;
|
||||
DropZoneWidget.prototype.leaveDrag = function(event) {
|
||||
var pos = this.currentlyEntered.indexOf(event.target);
|
||||
if(pos !== -1) {
|
||||
this.currentlyEntered.splice(pos,1);
|
||||
}
|
||||
// Remove highlighting if we're leaving externally
|
||||
if(this.dragEnterCount <= 0) {
|
||||
if(this.currentlyEntered.length === 0) {
|
||||
$tw.utils.removeClass(this.domNodes[0],"tc-dragover");
|
||||
}
|
||||
};
|
||||
|
||||
DropZoneWidget.prototype.handleDragEnterEvent = function(event) {
|
||||
this.enterDrag();
|
||||
// Check for this window being the source of the drag
|
||||
if($tw.dragInProgress) {
|
||||
return false;
|
||||
}
|
||||
this.enterDrag(event);
|
||||
// Tell the browser that we're ready to handle the drop
|
||||
event.preventDefault();
|
||||
// Tell the browser not to ripple the drag up to any parent drop handlers
|
||||
@ -97,11 +100,11 @@ DropZoneWidget.prototype.handleDragOverEvent = function(event) {
|
||||
};
|
||||
|
||||
DropZoneWidget.prototype.handleDragLeaveEvent = function(event) {
|
||||
this.leaveDrag();
|
||||
this.leaveDrag(event);
|
||||
};
|
||||
|
||||
DropZoneWidget.prototype.handleDropEvent = function(event) {
|
||||
this.leaveDrag();
|
||||
this.leaveDrag(event);
|
||||
// Check for being over a TEXTAREA or INPUT
|
||||
if(["TEXTAREA","INPUT"].indexOf(event.target.tagName) !== -1) {
|
||||
return false;
|
||||
@ -112,8 +115,6 @@ DropZoneWidget.prototype.handleDropEvent = function(event) {
|
||||
}
|
||||
var self = this,
|
||||
dataTransfer = event.dataTransfer;
|
||||
// Reset the enter count
|
||||
this.dragEnterCount = 0;
|
||||
// Remove highlighting
|
||||
$tw.utils.removeClass(this.domNodes[0],"tc-dragover");
|
||||
// Import any files in the drop
|
||||
|
Loading…
x
Reference in New Issue
Block a user