From fd4c485c1a1f53c734396f0bef5ece02afb3acc9 Mon Sep 17 00:00:00 2001
From: Benoit Socias <bso@odoo.com>
Date: Wed, 19 Apr 2023 08:12:34 +0000
Subject: [PATCH] [FIX] website: neutralize sub-pixel height difference in
 images wall

Inside the Images Wall snippet, images are dispatched to columns
depending on the height already reached by each column. This computation
relies on a sub-pixel height which leads to a confusing behavior.

This commit rounds the sub-pixel height to a visible pixel height to
avoid the confusion.

Steps to reproduce:
In the default images of the Images Wall snippet, the third image (sign)
is one pixel taller than the other ones.
- Drop an Images Wall snippet.
- Select the "sign" image.
- Move it to the first position.
(Because of another bug involving a race condition with the loading of
images, you might observe a different behavior. Move to first position
again to recompute the layout several times.)

=> The compass image moved to the first column.

task-2990053

X-original-commit: 1fc45be924e904dc595af61e0845b91cc5d24a49
Part-of: odoo/odoo#124608
---
 addons/website/static/src/snippets/s_image_gallery/options.js | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/addons/website/static/src/snippets/s_image_gallery/options.js b/addons/website/static/src/snippets/s_image_gallery/options.js
index 328814f9b27b..1838870a252c 100644
--- a/addons/website/static/src/snippets/s_image_gallery/options.js
+++ b/addons/website/static/src/snippets/s_image_gallery/options.js
@@ -203,6 +203,8 @@ options.registry.gallery = options.Class.extend({
             _.each(cols, function (col) {
                 var $col = $(col);
                 var height = $col.is(':empty') ? 0 : $col.find('img').last().offset().top + $col.find('img').last().height() - self.$target.offset().top;
+                // Neutralize invisible sub-pixel height differences.
+                height = Math.round(height);
                 if (height < min) {
                     min = height;
                     $lowest = $col;
-- 
GitLab