diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index 12b34d04138..4d209042509 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -6754,6 +6754,13 @@ registry.ImageTools = ImageHandlerOption.extend({ } } await this._reapplyCurrentShape(); + // When the hover effects are first activated from the "animationMode" + // function of the "WebsiteAnimate" class, the history was paused to + // avoid recording intermediate steps. That's why we unpause it here. + if (this.firstHoverEffect) { + this.options.wysiwyg.odooEditor.historyUnpauseSteps(); + delete this.firstHoverEffect; + } }, /** * @see this.selectClass for parameters @@ -6801,6 +6808,7 @@ registry.ImageTools = ImageHandlerOption.extend({ shapeImgSquareWidget.getParent().close(); // FIXME remove this ugly hack asap } // Add the "Overlay" hover effect to the shape. + this.firstHoverEffect = true; const hoverEffectOverlayWidget = this._requestUserValueWidgets("hover_effect_overlay_opt")[0]; hoverEffectOverlayWidget.enable(); hoverEffectOverlayWidget.getParent().close(); // FIXME remove this ugly hack asap diff --git a/addons/website/static/src/js/content/snippets.animation.js b/addons/website/static/src/js/content/snippets.animation.js index 17f24dda245..9bc48f935cf 100644 --- a/addons/website/static/src/js/content/snippets.animation.js +++ b/addons/website/static/src/js/content/snippets.animation.js @@ -1776,7 +1776,7 @@ registry.ImageShapeHoverEffet = publicWidget.Widget.extend({ * @private */ _onMouseEnter() { - if (!this.originalImgSrc) { + if (!this.originalImgSrc || !this.$target[0].dataset.hoverEffect) { return; } this.lastMouseEvent = this.lastMouseEvent.then(() => new Promise((resolve) => { @@ -1812,7 +1812,7 @@ registry.ImageShapeHoverEffet = publicWidget.Widget.extend({ */ _onMouseLeave() { this.lastMouseEvent = this.lastMouseEvent.then(() => new Promise((resolve) => { - if (!this.originalImgSrc || !this.svgInEl) { + if (!this.originalImgSrc || !this.svgInEl || !this.$target[0].dataset.hoverEffect) { resolve(); return; } diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index d1ed6f4b55f..3cf21b0d27a 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -3557,6 +3557,10 @@ options.registry.WebsiteAnimate = options.Class.extend({ this._toggleImagesLazyLoading(true); } if (widgetValue === "onHover") { + // Pause the history until the hover effect is applied in + // "setImgShapeHoverEffect". This prevents saving the intermediate + // steps done (in a tricky way) up to that point. + this.options.wysiwyg.odooEditor.historyPauseSteps(); this.trigger_up("option_update", { optionName: "ImageTools", name: "enable_hover_effect",