From 82a8a3d13d8eb3fb78b387701f84d5418bd2588f Mon Sep 17 00:00:00 2001 From: Philipp Date: Fri, 4 Aug 2023 10:34:21 +0200 Subject: [PATCH] feat(context-pad): support `mouseover` and `mouseout` --- lib/features/context-pad/ContextPad.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/features/context-pad/ContextPad.js b/lib/features/context-pad/ContextPad.js index a86d9074a..acb549e43 100644 --- a/lib/features/context-pad/ContextPad.js +++ b/lib/features/context-pad/ContextPad.js @@ -229,11 +229,19 @@ ContextPad.prototype.trigger = function(action, event, autoActivate) { entry = domAttr(button, 'data-action'); originalEvent = event.originalEvent || event; + if (action === 'mouseover') { + this._mouseout = this.triggerEntry(entry, 'hover', originalEvent, autoActivate); + } else if (action === 'mouseout' && this._mouseout) { + this._mouseout(); + + this._mouseout = null; + } + return this.triggerEntry(entry, action, originalEvent, autoActivate); }; /** - * Trigger context pad entry entry. + * Trigger action on context pad entry entry, e.g. click, mouseover or mouseout. * * @param {string} entryId * @param {string} action @@ -391,6 +399,14 @@ ContextPad.prototype.getPad = function(target) { self.trigger('dragstart', event); }); + domDelegate.bind(html, entrySelector, 'mouseover', function(event) { + self.trigger('mouseover', event); + }); + + domDelegate.bind(html, entrySelector, 'mouseout', function(event) { + self.trigger('mouseout', event); + }); + // stop propagation of mouse events domEvent.bind(html, 'mousedown', function(event) { event.stopPropagation();