diff --git a/addons/website/static/src/js/content/snippets.animation.js b/addons/website/static/src/js/content/snippets.animation.js index 76bb7c66f24..7de8fbef029 100644 --- a/addons/website/static/src/js/content/snippets.animation.js +++ b/addons/website/static/src/js/content/snippets.animation.js @@ -553,15 +553,11 @@ registry.Parallax = Animation.extend({ this.ratio = this.speed * (this.viewport / 10); // Provide a "safe-area" to limit parallax + const absoluteRatio = Math.abs(this.ratio); this.$bg.css({ - top: -this.ratio, - bottom: -this.ratio, + top: -absoluteRatio, + bottom: -absoluteRatio, }); - - // Get parallax direction - if (this.el.dataset.scrollBackgroundDirection === 'bottom') { - this.ratio = -this.ratio; - } }, //-------------------------------------------------------------------------- diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index e8be8995e21..b4c6191d2b5 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -1665,9 +1665,28 @@ options.registry.Parallax = options.Class.extend({ /** * @override */ - async _computeVisibility() { + async _computeVisibility(widgetName) { return !this.$target.hasClass('o_background_video'); }, + /** + * @override + */ + async _computeWidgetState(methodName, params) { + if (methodName === 'selectDataAttribute' && params.parallaxTypeOpt) { + const attrName = params.attributeName; + const attrValue = (this.$target[0].dataset[attrName] || params.attributeDefaultValue).trim(); + switch (attrValue) { + case '0': + case '1': { + return attrValue; + } + default: { + return (attrValue.startsWith('-') ? '-1.5' : '1.5'); + } + } + } + return this._super(...arguments); + }, /** * Updates external background-related option to work with the parallax * element instead of the original target when necessary. diff --git a/addons/website/views/snippets/snippets.xml b/addons/website/views/snippets/snippets.xml index cea28813620..5f3f3a63bb2 100644 --- a/addons/website/views/snippets/snippets.xml +++ b/addons/website/views/snippets/snippets.xml @@ -144,23 +144,32 @@ None Fixed - Very Slow - Slow - Fast - Very Fast - - - Bottom to Top - Top to Bottom + Bottom to Top + Top to Bottom + +