Skip to content

Commit

Permalink
Merge pull request #125 from RickyDane/feature/drag_to_path
Browse files Browse the repository at this point in the history
Feature/drag to path
  • Loading branch information
RickyDane authored Aug 15, 2024
2 parents 6e83fef + 8a34973 commit 11ed4e8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# cargo-features = ["profile-rustflags"]
[package]
name = "CoDriver"
version = "0.4.81"
version = "0.4.82"
description = "A simple file explorer"
authors = ["Ricky Dane Perlick"]
license = "none"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "CoDriver",
"version": "0.4.81"
"version": "0.4.82"
},
"tauri": {
"bundle": {
Expand Down
23 changes: 16 additions & 7 deletions ui/main_logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ function closeAllPopups() {
if (ArrCopyItems.length == 0) {
IsCopyToCut = false;
}
$(".path-item")?.css("opacity", "1");
}
// Close context menu or new folder input dialog when click elsewhere
document.addEventListener("mousedown", (e) => {
Expand Down Expand Up @@ -642,7 +643,7 @@ document.onkeydown = async (e) => {
e.stopPropagation();
}
// check if backspace is pressed
if (e.keyCode == 8 && IsPopUpOpen === false && IsInputFocused === false) {
if (e.keyCode == 8 && IsPopUpOpen === false && IsInputFocused === false && ArrSelectedItems.length == 0) {
goBack();
e.preventDefault();
e.stopPropagation();
Expand Down Expand Up @@ -1050,17 +1051,14 @@ async function showItems(items, dualPaneSide = "", millerCol = 1) {
Platform != "darwin" &&
(Platform.includes("win") || Platform.includes("linux"))
) {
IsFileOpIntern = true;
await startDrag({ item: arr, icon: icon });
unSelectAllItems();
refreshView();
} else {
IsFileOpIntern = true;
await startDrag({ item: arr, icon: icon });
unSelectAllItems();
refreshView();
}
IsFileOpIntern = false;
};
// Accept file drop into folders
item.addEventListener("dragover", (e) => {
Expand Down Expand Up @@ -1621,11 +1619,9 @@ async function addSingleItem(item, dualPaneSide = "", millerCol = 1) {
) {
await startDrag({ item: arr, icon: "" });
unSelectAllItems();
IsFileOpIntern = true;
} else {
await startDrag({ item: arr, icon: icon });
unSelectAllItems();
IsFileOpIntern = true;
}
};
// Accept file drop into folders
Expand Down Expand Up @@ -1910,6 +1906,16 @@ async function setCurrentDir(currentDir = "", dualPaneSide = "") {
"onClick",
"openItem(this, '" + dualPaneSide + "', '')",
);
pathItem.ondragover = (e) => {
MousePos = [e.clientX, e.clientY-60];
e.preventDefault();
pathItem.style.opacity = 0.5;
DraggedOverElement = pathItem;
}
pathItem.ondragleave = (e) => {
e.preventDefault();
pathItem.style.opacity = 1;
}
let divider = document.createElement("i");
divider.className = "fa fa-chevron-right";
divider.style.color = "var(--textColor)";
Expand Down Expand Up @@ -2526,7 +2532,7 @@ async function checkAppConfig() {
}
checkColorMode(appConfig);
});

await unSelectAllItems();
IsFirstRun = false;
}

Expand Down Expand Up @@ -2815,6 +2821,8 @@ async function openItem(element, dualPaneSide, shortcutDirPath = null) {
SelectedItemPaneSide = dualPaneSide;
await listDirectories();
}
await setCurrentDir(path);
await unSelectAllItems();
} else {
alert("Could not open directory");
return;
Expand Down Expand Up @@ -4521,6 +4529,7 @@ async function openDirAndSwitch(path) {
await invoke("open_dir", { path });
await setCurrentDir(path);
await listDirectories();
await unSelectAllItems();
}

async function openConfigLocation() {
Expand Down
4 changes: 3 additions & 1 deletion ui/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ listen("tauri://file-drop", async (event) => {
DraggedOverElement = null;
}
} catch (error) {
await invoke("log", { log: error });
await invoke("log", { log: JSON.stringify(error) });
IsFileOpIntern = false;
alert(error);
}
resetProgressBar();
IsFileOpIntern = false;
document.querySelectorAll(".site-nav-bar-button").forEach((item) => {
item.style.opacity = "1";
});
Expand Down

0 comments on commit 11ed4e8

Please sign in to comment.