Skip to content

Commit

Permalink
dia.Paper: make sure paper:mouseenter event is always triggered (#1639)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumilingus authored Mar 28, 2022
1 parent ff74298 commit 31a8dfa
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/dia/Paper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2136,18 +2136,32 @@ export const Paper = View.extend({

evt = normalizeEvent(evt);

var view = this.findView(evt.target);
const {
target, // The EventTarget the pointing device entered to
relatedTarget // The EventTarget the pointing device exited from
} = evt;
const view = this.findView(target);
if (this.guard(evt, view)) return;
var relatedView = this.findView(evt.relatedTarget);
const relatedView = this.findView(relatedTarget);
if (view) {
// mouse moved from tool over view?
if (relatedView === view) return;
if (relatedView === view) {
// Mouse left a cell tool
return;
}
// prevent double `mouseenter` event if the `relatedTarget` is outside the paper
// (mouseenter method would be fired twice)
evt.stopPropagation();
view.mouseenter(evt);
} else {
if (relatedView) return;
// `paper` (more descriptive), not `blank`
this.trigger('paper:mouseenter', evt);
if (this.el.contains(relatedTarget)) {
// The pointer remains inside the paper.
return;
}
}
if (relatedView) {
return;
}
// `paper` (more descriptive), not `blank`
this.trigger('paper:mouseenter', evt);
},

mouseleave: function(evt) {
Expand Down

0 comments on commit 31a8dfa

Please sign in to comment.