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
This commit is contained in:
Raymond Hill 2023-07-03 07:14:52 -04:00
parent e52da39839
commit 60b21b1422
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 2 additions and 2 deletions

View File

@ -101,7 +101,7 @@ const onStartMovingWidget = (( ) => {
const move = ( ) => { const move = ( ) => {
timer = undefined; 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) ) { if ( (l1+cw/2) < (pw/2) ) {
widget.style.left = `${l1/pw*100}%`; widget.style.left = `${l1/pw*100}%`;
widget.style.right = ''; widget.style.right = '';
@ -109,7 +109,7 @@ const onStartMovingWidget = (( ) => {
widget.style.right = `${(pw-l1-cw)/pw*100}%`; widget.style.right = `${(pw-l1-cw)/pw*100}%`;
widget.style.left = ''; 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.top = `${t1/ph*100}%`;
widget.style.bottom = ''; widget.style.bottom = '';
}; };