From b8bf3f3ddd18c0da41922f7234fee9b9111b2481 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 8 Jun 2022 22:18:05 +0800 Subject: [PATCH] Fix viewed images not loading in a PR --- web_src/js/features/imagediff.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web_src/js/features/imagediff.js b/web_src/js/features/imagediff.js index 1745331768482..0b021d070fb05 100644 --- a/web_src/js/features/imagediff.js +++ b/web_src/js/features/imagediff.js @@ -67,7 +67,8 @@ export default function initImageDiff() { $('.image-diff').each(function() { const $container = $(this); - const diffContainerWidth = $container.width() - 300; + // the container may be hidden by "viewed" checkbox, so use the parent's width for reference + const diffContainerWidth = Math.max($container.closest('.diff-file-box').width() - 300, 100); const pathAfter = $container.data('path-after'); const pathBefore = $container.data('path-before');