diff --git a/src/app/shared/system-component/menu/menu.component.html b/src/app/shared/system-component/menu/menu.component.html index a6e77be3..88318359 100644 --- a/src/app/shared/system-component/menu/menu.component.html +++ b/src/app/shared/system-component/menu/menu.component.html @@ -4,7 +4,7 @@ -
+
@@ -41,7 +41,7 @@ -
+
@@ -95,10 +95,10 @@ -
+
-
+
@@ -120,7 +120,7 @@
-
+
diff --git a/src/app/system-apps/fileexplorer/fileexplorer.component.ts b/src/app/system-apps/fileexplorer/fileexplorer.component.ts index 0f8b50f3..2a285f8c 100644 --- a/src/app/system-apps/fileexplorer/fileexplorer.component.ts +++ b/src/app/system-apps/fileexplorer/fileexplorer.component.ts @@ -64,6 +64,7 @@ export class FileExplorerComponent implements BaseComponent, OnInit, AfterViewIn private isIconInFocusDueToPriorAction = false; private isBtnClickEvt= false; private isHideCntxtMenuEvt= false; + private isShiftSubMenuLeft = false; private selectedFile!:FileInfo; private selectedElementId = -1; @@ -82,10 +83,6 @@ export class FileExplorerComponent implements BaseComponent, OnInit, AfterViewIn showInformationTip = false; iconCntxtCntr = 0; fileExplrCntxtCntr = 0; - - currentXPosition = 0; - currentYPosition = 0; - //hideInformationTip = false; fileExplrCntxtMenuStyle:Record = {}; @@ -895,6 +892,7 @@ export class FileExplorerComponent implements BaseComponent, OnInit, AfterViewIn onHideIconContextMenu():void{ this.showIconCntxtMenu = false; this.showFileExplrCntxtMenu = false; + this.isShiftSubMenuLeft = false; this.iconCntxtCntr = 0; this.fileExplrCntxtCntr = 0; @@ -931,7 +929,7 @@ export class FileExplorerComponent implements BaseComponent, OnInit, AfterViewIn } } - onShowFileExplorerContextMenu(evt:MouseEvent,):void{ + onShowFileExplorerContextMenu(evt:MouseEvent):void{ this.fileExplrCntxtCntr++; if(this.iconCntxtCntr >= this.fileExplrCntxtCntr) @@ -942,27 +940,28 @@ export class FileExplorerComponent implements BaseComponent, OnInit, AfterViewIn } const rect = this.fileExplrCntntCntnr.nativeElement.getBoundingClientRect(); - // console.log('rect:', rect); - // console.log('evt:',evt); - - const horizontalMin = rect.x; - const horizontalMax = rect.right - const verticalMin = rect.top; - const verticalMax = rect.bottom; - - let x = 0; - let y = 0; - - if((horizontalMax - evt.clientX) >= 0 && (horizontalMax - evt.clientX) <= 25){ - x = evt.clientX - rect.left - 25; - this.currentXPosition = x; - y = evt.clientY - rect.top; - this.currentYPosition = y; - }else{ - - x = evt.clientX - rect.left; - y = evt.clientY - rect.top; - } + console.log('rect:', rect); + console.log('evt:',evt); + + // const horizontalMin = rect.x; + // const horizontalMax = rect.right + // const verticalMin = rect.top; + // const verticalMax = rect.bottom; + + const axis = this.checkAndHandleMenuBounds(rect, evt); + // let x = 0; + // let y = 0; + + // if((horizontalMax - evt.clientX) >= 0 && (horizontalMax - evt.clientX) <= 10){ + // x = evt.clientX - rect.left - 10; + // this.currentXPosition = x; + // y = evt.clientY - rect.top; + // this.currentYPosition = y; + // }else{ + + // x = evt.clientX - rect.left; + // y = evt.clientY - rect.top; + // } // console.log(`horizontalMin:${horizontalMin} horizontalMax:${horizontalMax} verticalMin:${verticalMin} verticalMax:${verticalMax}`); @@ -976,18 +975,59 @@ export class FileExplorerComponent implements BaseComponent, OnInit, AfterViewIn this.fileExplrCntxtMenuStyle = { 'position': 'absolute', - 'transform':`translate(${String(x)}px, ${String(y)}px)`, + 'transform':`translate(${String(axis.xAxis)}px, ${String(axis.yAxis)}px)`, 'z-index': 2, } evt.preventDefault(); } - moveNestMenuOver():void{ - const fileExplrNestedMenu = document.getElementById("dmfileExplrNestedMenu") as HTMLDivElement; - console.log('fileExplrNestedMenu:',fileExplrNestedMenu); + checkAndHandleMenuBounds(rect:DOMRect, evt:MouseEvent):{ xAxis: number; yAxis: number; }{ + + let xAxis = 0; + let yAxis = 0; + //const horizontalMin = rect.x; + const horizontalMax = rect.right + //const verticalMin = rect.top; + const verticalMax = rect.bottom; + const horizontalDiff = horizontalMax - evt.clientX; + const verticalDiff = verticalMax - evt.clientY; + const menuHeight = 230; //get menu height here + let horizontalShift = false; + let verticalShift = false; + + if((horizontalDiff) >= 0 && (horizontalDiff) <= 10){ + this.isShiftSubMenuLeft = true; + horizontalShift = true; + + xAxis = evt.clientX - rect.left - horizontalDiff; + } + + if((verticalDiff) >= 40 && (verticalDiff) <= menuHeight){ + const shifMenuUpBy = menuHeight - verticalDiff; + verticalShift = true; + + yAxis = evt.clientY - rect.top - shifMenuUpBy; + } + + xAxis = (horizontalShift)? xAxis : evt.clientX - rect.left; + yAxis = (verticalShift)? yAxis : evt.clientY - rect.top; + + return {xAxis, yAxis}; + } + + shiftViewSubMenu():void{ this.shiftNestedMenuPosition(0); } + + shiftSortBySubMenu():void{this.shiftNestedMenuPosition(1); } + + shiftNewSubMenu():void { this.shiftNestedMenuPosition(6); } + + shiftNestedMenuPosition(i:number):void{ + const fileExplrNestedMenu = document.getElementById(`dmfileExplrNestedMenu-${i}`) as HTMLDivElement; + if(fileExplrNestedMenu){ + if(this.isShiftSubMenuLeft) + fileExplrNestedMenu.style.left = '-98%'; + } - if(fileExplrNestedMenu) - fileExplrNestedMenu.style.left = '-98%'; } onDragStart(evt:any):void{ @@ -1070,8 +1110,6 @@ export class FileExplorerComponent implements BaseComponent, OnInit, AfterViewIn setInformationTipInfo(file:FileInfo):void{ - //console.log('file:',file); - const infoTipFields = ['Author:', 'Item type:','Date created:','Date modified:', 'Dimesions:', 'General', 'Size:','Type:']; const fileAuthor = 'Relampago Del Catatumbo'; const fileType = file.getFileType; @@ -1560,7 +1598,7 @@ export class FileExplorerComponent implements BaseComponent, OnInit, AfterViewIn } - buildViewByMenu():NestedMenuItem[]{ + buildViewMenu():NestedMenuItem[]{ const extraLargeIcon:NestedMenuItem={ icon:'osdrive/icons/circle.png', label:'Extra Large icons', action: () => this.isExtraLargeIcon = !this.isExtraLargeIcon, variables:this.isExtraLargeIcon, emptyline:false, styleOption:'A' } @@ -1621,13 +1659,13 @@ export class FileExplorerComponent implements BaseComponent, OnInit, AfterViewIn getFileExplorerMenuData():void{ this.fileExplrMenu = [ - {icon1:'', icon2: 'osdrive/icons/arrow_next_1.png', label:'View', nest:this.buildViewByMenu(), action: ()=> '', action1: this.moveNestMenuOver.bind(this), emptyline:false}, - {icon1:'', icon2:'osdrive/icons/arrow_next_1.png', label:'Sort by', nest:this.buildSortByMenu(), action: ()=> '', action1: ()=> '', emptyline:false}, + {icon1:'', icon2: 'osdrive/icons/arrow_next_1.png', label:'View', nest:this.buildViewMenu(), action: ()=> '', action1: this.shiftViewSubMenu.bind(this), emptyline:false}, + {icon1:'', icon2:'osdrive/icons/arrow_next_1.png', label:'Sort by', nest:this.buildSortByMenu(), action: ()=> '', action1: this.shiftSortBySubMenu.bind(this), emptyline:false}, {icon1:'', icon2:'', label: 'Refresh', nest:[], action:() => console.log('Refresh'), action1: ()=> '', emptyline:true}, {icon1:'', icon2:'', label: 'Paste', nest:[], action: () => console.log('Paste!! Paste!!'), action1: ()=> '', emptyline:false}, {icon1:'/osdrive/icons/terminal_48.png', icon2:'', label:'Open in Terminal', nest:[], action: () => console.log('Open Terminal'), action1: ()=> '', emptyline:false}, {icon1:'osdrive/icons/vs-code_48.png', icon2:'', label:'Open with Code', nest:[], action: () => console.log('Open CodeEditor'), action1: ()=> '', emptyline:true}, - {icon1:'', icon2:'osdrive/icons/arrow_next_1.png', label:'New', nest:this.buildNewMenu(), action: ()=> console.log(), action1: ()=> '', emptyline:true}, + {icon1:'', icon2:'osdrive/icons/arrow_next_1.png', label:'New', nest:this.buildNewMenu(), action: ()=> '', action1: this.shiftNewSubMenu.bind(this), emptyline:true}, {icon1:'', icon2:'', label:'Properties', nest:[], action: () => console.log('Properties'), action1: ()=> '', emptyline:false} ] }