Skip to content

Commit

Permalink
Prevent negative position when widget size is greater than viewport size
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jul 3, 2023
1 parent e52da39 commit 60b21b1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/js/logger-ui.js
Expand Up @@ -101,15 +101,15 @@ 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 = '';
} else {
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 = '';
};
Expand Down

1 comment on commit 60b21b1

@gwarser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.