Skip to content

Commit

Permalink
minor adjustments to bounds checking
Browse files Browse the repository at this point in the history
  • Loading branch information
chinonso098 committed Sep 6, 2024
1 parent 7bb9aa8 commit 5b4c228
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/app/system-apps/desktop/desktop.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ export class DesktopComponent implements OnInit, OnDestroy, AfterViewInit{
let xAxis = 0;
let yAxis = 0;
const menuWidth = 210;

//console.log(`translate(${String(evt.clientX + 2)}px, ${String(evt.clientY)}px)`);
const taskBarHeight = 40;

const mainWindow = document.getElementById('vanta');
const windowWidth = mainWindow?.offsetWidth || 0;
Expand All @@ -289,24 +288,20 @@ export class DesktopComponent implements OnInit, OnDestroy, AfterViewInit{
const horizontalDiff = windowWidth - evt.clientX;
const verticalDiff = windowHeight - evt.clientY;

// console.log('horizontalDiff:', horizontalDiff);
// console.log('verticalDiff:',verticalDiff);

let horizontalShift = false;
let verticalShift = false;

if((horizontalDiff) < menuWidth){
this.isShiftSubMenuLeft = true;
horizontalShift = true;
const diff = menuWidth - horizontalDiff;
xAxis = evt.clientX - horizontalDiff - diff;
xAxis = evt.clientX - diff;
}

if((verticalDiff) >= 40 && (verticalDiff) <= menuHeight){
if((verticalDiff) >= taskBarHeight && (verticalDiff) <= menuHeight){
const shifMenuUpBy = menuHeight - verticalDiff;
verticalShift = true;

yAxis = evt.clientY - shifMenuUpBy;
yAxis = evt.clientY - shifMenuUpBy - taskBarHeight;
}

xAxis = (horizontalShift)? xAxis : evt.clientX;
Expand Down

0 comments on commit 5b4c228

Please sign in to comment.