From 60b21b14226807bd697174caeb2f2ba4a9626ade Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 3 Jul 2023 07:14:52 -0400 Subject: [PATCH] Prevent negative position when widget size is greater than viewport size Related issues: - https://github.com/uBlockOrigin/uBlock-issues/issues/2718 - https://github.com/uBlockOrigin/uBlock-issues/issues/2704 --- src/js/logger-ui.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/logger-ui.js b/src/js/logger-ui.js index 9fedb71308933..34414129fa89d 100644 --- a/src/js/logger-ui.js +++ b/src/js/logger-ui.js @@ -101,7 +101,7 @@ const onStartMovingWidget = (( ) => { const move = ( ) => { timer = undefined; - const l1 = Math.min(Math.max(l0 + mx1 - mx0, 0), pw - cw); + const l1 = Math.min(Math.max(l0 + mx1 - mx0, 0), Math.max(pw - cw, 0)); if ( (l1+cw/2) < (pw/2) ) { widget.style.left = `${l1/pw*100}%`; widget.style.right = ''; @@ -109,7 +109,7 @@ const onStartMovingWidget = (( ) => { widget.style.right = `${(pw-l1-cw)/pw*100}%`; widget.style.left = ''; } - const t1 = Math.min(Math.max(t0 + my1 - my0, 0), ph - ch); + const t1 = Math.min(Math.max(t0 + my1 - my0, 0), Math.max(ph - ch, 0)); widget.style.top = `${t1/ph*100}%`; widget.style.bottom = ''; };