mirror of https://github.com/keeweb/keeweb.git
Avoid spurious drop-target indications
While app-view already prevented the default action for files and urls in a browser window (navigation), the drag indicator showed that any drop was possible. These changes cause the drag indicator to show that nothing can be dropped on areas of the interface that don't contain a drop target. The addition of dragenter avoids some flickering which otherwise can occur when dragging a file rapidly across the group or entry lists. Accompanying changes to details-view, menu-item-view and open-view are needed because those views relied on "inheriting" from app-view the indication that dropping anything was allowed.
This commit is contained in:
parent
7a3cc9c863
commit
2450e3a0b6
|
@ -31,6 +31,7 @@ const AppView = Backbone.View.extend({
|
|||
events: {
|
||||
'contextmenu': 'contextMenu',
|
||||
'drop': 'drop',
|
||||
'dragenter': 'dragover',
|
||||
'dragover': 'dragover',
|
||||
'click a[target=_blank]': 'extLinkClick',
|
||||
'mousedown': 'bodyClick'
|
||||
|
@ -678,6 +679,7 @@ const AppView = Backbone.View.extend({
|
|||
|
||||
dragover: function(e) {
|
||||
e.preventDefault();
|
||||
e.originalEvent.dataTransfer.dropEffect = 'none';
|
||||
},
|
||||
|
||||
drop: function(e) {
|
||||
|
|
|
@ -564,6 +564,7 @@ const DetailsView = Backbone.View.extend({
|
|||
|
||||
dragover: function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
const dt = e.originalEvent.dataTransfer;
|
||||
if (!dt.types || (dt.types.indexOf ? dt.types.indexOf('Files') === -1 : !dt.types.contains('Files'))) {
|
||||
dt.dropEffect = 'none';
|
||||
|
|
|
@ -199,8 +199,8 @@ const MenuItemView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
dragover(e) {
|
||||
e.stopPropagation();
|
||||
if (this.model.get('drop') && this.dropAllowed(e)) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
this.$el.addClass('menu__item--drag');
|
||||
}
|
||||
|
|
|
@ -433,6 +433,13 @@ const OpenView = Backbone.View.extend({
|
|||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
const dt = e.originalEvent.dataTransfer;
|
||||
if (!dt.types || (dt.types.indexOf ? dt.types.indexOf('Files') === -1 : !dt.types.contains('Files'))) {
|
||||
dt.dropEffect = 'none';
|
||||
return;
|
||||
}
|
||||
dt.dropEffect = 'copy';
|
||||
if (this.dragTimeout) {
|
||||
clearTimeout(this.dragTimeout);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue