mirror of https://github.com/gorhill/uBlock.git
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:
parent
e52da39839
commit
60b21b1422
|
@ -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 = '';
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue