diff --git a/addons/web/static/src/legacy/js/core/smooth_scroll_on_drag.js b/addons/web/static/src/legacy/js/core/smooth_scroll_on_drag.js index 28a4beff4c4..37aae5f1f44 100644 --- a/addons/web/static/src/legacy/js/core/smooth_scroll_on_drag.js +++ b/addons/web/static/src/legacy/js/core/smooth_scroll_on_drag.js @@ -90,6 +90,7 @@ const SmoothScrollOnDrag = Class.extend(mixins.ParentedMixin, { * @param {jQuery} [options.offsetElements.$left] Visible left offset element which width * will be taken into account when triggering scroll at the left side of the * $scrollTarget. + * @param {boolean} [options.disableHorizontalScroll = false] Disable horizontal scroll if not needed. */ init(parent, $element, $scrollTarget, options = {}) { mixins.ParentedMixin.init.call(this); @@ -126,6 +127,7 @@ const SmoothScrollOnDrag = Class.extend(mixins.ParentedMixin, { }; this.options.jQueryDraggableOptions.scroll = false; + this.options.disableHorizontalScroll = this.options.disableHorizontalScroll || false; const draggableOptions = Object.assign({}, this.options.jQueryDraggableOptions, { start: (ev, ui) => this._onSmoothDragStart(ev, ui, this.options.jQueryDraggableOptions.start), drag: (ev, ui) => this._onSmoothDrag(ev, ui, this.options.jQueryDraggableOptions.drag), @@ -203,10 +205,12 @@ const SmoothScrollOnDrag = Class.extend(mixins.ParentedMixin, { this.$scrollTarget.scrollTop() + this.verticalDelta ); - this.$scrollTarget.scrollLeft( - this.$scrollTarget.scrollLeft() + - this.horizontalDelta - ); + if (!this.options.disableHorizontalScroll) { + this.$scrollTarget.scrollLeft( + this.$scrollTarget.scrollLeft() + + this.horizontalDelta + ); + } }, this.options.scrollTimerInterval ); diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index 73afcc1f3cf..c8990657713 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -2182,6 +2182,7 @@ var SnippetsMenu = Widget.extend({ greedy: true, scroll: false, }, options.jQueryDraggableOptions), + disableHorizontalScroll: true, }); }, /**