From 030f4f1cff5350f4cd2252eb9cb59bc8b1449d11 Mon Sep 17 00:00:00 2001 From: chinonso098 Date: Mon, 7 Oct 2024 15:17:19 -0400 Subject: [PATCH] drag n drop still a work in progress --- .../filemanager/filemanager.component.css | 9 ++++ .../filemanager/filemanager.component.html | 16 ++++-- .../filemanager/filemanager.component.ts | 52 +++++++++++++++---- 3 files changed, 64 insertions(+), 13 deletions(-) diff --git a/src/app/system-apps/filemanager/filemanager.component.css b/src/app/system-apps/filemanager/filemanager.component.css index b29f8b6..c455293 100644 --- a/src/app/system-apps/filemanager/filemanager.component.css +++ b/src/app/system-apps/filemanager/filemanager.component.css @@ -141,3 +141,12 @@ input::selection{ left: 20px; transform: rotate(180deg); } + + +.clone-container{ + width: fit-content; + height: fit-content; + background-color: #ccc; + z-index: 5; + position: absolute; +} \ No newline at end of file diff --git a/src/app/system-apps/filemanager/filemanager.component.html b/src/app/system-apps/filemanager/filemanager.component.html index 35b7a88..3c064d9 100644 --- a/src/app/system-apps/filemanager/filemanager.component.html +++ b/src/app/system-apps/filemanager/filemanager.component.html @@ -1,11 +1,11 @@
    -
  1. +
+ + + \ No newline at end of file diff --git a/src/app/system-apps/filemanager/filemanager.component.ts b/src/app/system-apps/filemanager/filemanager.component.ts index c18f294..f5a8b68 100644 --- a/src/app/system-apps/filemanager/filemanager.component.ts +++ b/src/app/system-apps/filemanager/filemanager.component.ts @@ -53,6 +53,8 @@ export class FileManagerComponent implements BaseComponent, OnInit, AfterViewIni private isBtnClickEvt= false; private isHideCntxtMenuEvt= false; + isDraggable = true; + private selectedFile!:FileInfo; private propertiesViewFile!:FileInfo private selectedElementId = -1; @@ -61,8 +63,6 @@ export class FileManagerComponent implements BaseComponent, OnInit, AfterViewIni private btnClickCnt = 0; private renameFileTriggerCnt = 0; - - iconCntxtMenuStyle:Record = {}; iconSizeStyle:Record = {}; btnStyle:Record = {}; @@ -220,9 +220,10 @@ export class FileManagerComponent implements BaseComponent, OnInit, AfterViewIni // } } - onBtnClick(id:number):void{ + onBtnClick(evt:MouseEvent, id:number):void{ this.doBtnClickThings(id); this.setBtnStyle(id, true); + } onTriggerRunProcess():void{ @@ -365,15 +366,48 @@ export class FileManagerComponent implements BaseComponent, OnInit, AfterViewIni console.log('TODO:FileManagerComponent, Upgrade the basic state tracking/management logic:',transform); } - onDragStart(evt:any, i:number):void{ + onDragStart(evt:DragEvent, i:number):void{ + //this.isDraggable = true const btnIcon = document.getElementById(`liIconBtn${i}`) as HTMLElement - console.log('DragStart:',btnIcon); - if(btnIcon){ - // btnIcon.style.position = 'absolute'; - btnIcon.style.zIndex = '4'; + // console.log('DragStart:',btnIcon); + // if(btnIcon){ + // // btnIcon.style.position = 'absolute'; + // btnIcon.style.zIndex = '4'; + // } + // console.log('DragStart:',btnIcon); + } + + onDragStart_Off(evt:DragEvent, i: number): void { + + /** + * This method is mimick the functionality of Windows should a user attempt to drag n drop content from the + * desktop to the FileExplorer, or another application that support DnD + * + * The issue at the moment, is that it collide with the angular2-draggable functionailty. + * for the time being, it is Off + */ + + const iconA = document.getElementById(`filemngr_fig${i}`) as HTMLElement; + + // Get the cloneIcon container + const elementId = 'filemngr_clone_cntnr'; + const cloneIcon = document.getElementById(elementId); + + if(cloneIcon){ + // Clear any previous content in the clone container + cloneIcon.innerHTML = ''; + cloneIcon.appendChild(iconA.cloneNode(true)); + + cloneIcon.style.left = '-9999px'; // Move it out of view initially + cloneIcon.style.opacity = '0.2'; + + // Set the cloned icon as the drag image + if (evt.dataTransfer) { + evt.dataTransfer.setDragImage(cloneIcon, 0, 0); // Offset positions for the drag image + } } - console.log('DragStart:',btnIcon); } + onMouseEnter(id:number):void{ this.setBtnStyle(id, true);