Fix for mouseleave not being triggered during resize

[MAILPOET-1819]
This commit is contained in:
Rostislav Wolny
2019-02-27 17:29:28 +01:00
committed by M. Shull
parent 727240ca0c
commit 1b044f77a3
2 changed files with 18 additions and 0 deletions

View File

@ -10,11 +10,28 @@ BL.HighlightEditingBehavior = Marionette.Behavior.extend({
modelEvents: {
startEditing: 'onStartEditing',
stopEditing: 'onStopEditing',
resizeMove: 'onResizeMove',
},
events: {
mouseenter: 'onMouseEnter',
mouseleave: 'onMouseLeave',
},
// mouseleave event is not always triggered during resizing
// so we have to check if the pointer is still inside using resize event coordinates
onResizeMove: function onResizeMove(event) {
var offset = this.view.$el.offset();
var height = this.view.$el.height();
var width = this.view.$el.width();
if (event.pageX < offset.left
|| event.pageX > offset.left + width
|| event.pageY < offset.top
|| event.pageY > offset.top + height
) {
this.isFocusedByPointer = false;
} else {
this.isFocusedByPointer = true;
}
},
onMouseEnter: function onMouseEnter(mouseEvent) {
this.isFocusedByPointer = true;
// Ignore mouse events when dragging

View File

@ -59,6 +59,7 @@ BL.ResizableBehavior = Marionette.Behavior.extend({
that.$el.addClass('mailpoet_resize_active');
}).on('resizemove', function resizemove(event) {
var onResize = that.options.onResize.bind(that);
that.view.model.trigger('resizeMove', event);
return onResize(event);
})
.on('resizeend', function resizeend() {