summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/editor
diff options
context:
space:
mode:
authorBenjamin Vray <bvr@odoo.com>2020-08-17 08:34:08 +0000
committerBenjamin Vray <bvr@odoo.com>2020-10-21 10:35:59 +0000
commitb8ac4f6b0c0aaa17ccae43ad8756c5b807e29823 (patch)
treee5431b881ff64a301a1e5caab4d6288618cff283 /addons/web_editor/static/src/js/editor
parent86cd5e898b482192e50a20d0b6ef2a9b02b8301f (diff)
[FIX] web_editor: fix option background position
Keep the original position of the background as a percentage. In this way, we avoid converting in pixel a direction that we have not changed. Part of #55857 Related to task-2318526
Diffstat (limited to 'addons/web_editor/static/src/js/editor')
-rw-r--r--addons/web_editor/static/src/js/editor/snippets.options.js9
1 files changed, 6 insertions, 3 deletions
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 fef43257660..ae50244d7d7 100644
--- a/addons/web_editor/static/src/js/editor/snippets.options.js
+++ b/addons/web_editor/static/src/js/editor/snippets.options.js
@@ -4080,14 +4080,17 @@ registry.BackgroundPosition = SnippetOptionWidget.extend({
});
const position = this.$target.css('background-position').split(' ').map(v => parseInt(v));
- // Convert % values to pixels (because mouse movement is in pixels)
const delta = this._getBackgroundDelta();
+ // originalPosition kept in % for when movement in one direction doesn't make sense
this.originalPosition = {
+ left: position[0],
+ top: position[1],
+ };
+ // Convert % values to pixels for current position because mouse movement is in pixels
+ this.currentPosition = {
left: position[0] / 100 * delta.x || 0,
top: position[1] / 100 * delta.y || 0,
};
- this.currentPosition = _.clone(this.originalPosition);
-
this._toggleBgOverlay(true);
},
/**