add child level context menu

- more typescript
This commit is contained in:
geoffrey45
2022-03-16 01:21:53 +03:00
parent f11005e523
commit 29124ce717
14 changed files with 209 additions and 82 deletions
+14 -7
View File
@@ -17,20 +17,27 @@ export default (mouseX, mouseY) => {
const outOfBoundsOnY = scopeY + contextMenu.clientHeight > scope.clientHeight;
let normalizedX = mouseX;
let normalizedY = mouseY;
let normalX = mouseX;
let normalY = mouseY;
let normalizedX = false;
let normalizedY = false;
if (window.innerWidth - normalX < 375) {
normalizedX = true;
}
// ? normalize on X
if (outOfBoundsOnX) {
normalizedX = scopeOffsetX + scope.clientWidth - contextMenu.clientWidth;
normalizedX -= 10
normalX = scopeOffsetX + scope.clientWidth - contextMenu.clientWidth;
normalX -= 10;
}
// ? normalize on Y
if (outOfBoundsOnY) {
normalizedY = scopeOffsetY + scope.clientHeight - contextMenu.clientHeight;
normalizedY -= 10
normalY = scopeOffsetY + scope.clientHeight - contextMenu.clientHeight;
normalY -= 10;
normalizedY = true;
}
return { normalizedX, normalizedY };
return { normalX, normalY, normalizedX, normalizedY };
};
-82
View File
@@ -1,82 +0,0 @@
import { Track } from './../interfaces';
import Router from "../router";
interface Option {
type?: string;
label?: string;
action?: Function;
icon?: string;
critical?: Boolean;
}
/**
* Returns a list of context menu items for a track.
* @param {any} track a track object.
* @return {Array<Option>} a list of context menu items.
*/
export default (track: Track): Array<Option> => {
const option1: Option = {
label: "Add to Playlist",
action: () => console.log("Add to Playlist"),
icon: "plus",
};
const option2: Option = {
label: "Add to Queue",
action: () => console.log("Add to Queue"),
icon: "add_to_queue",
};
const option3: Option = {
label: "Go to Folder",
action: () => {
Router.push({
name: "FolderView",
params: { path: track.folder },
});
},
icon: "folder",
};
const option4: Option = {
label: "Go to Artist",
action: () => console.log("Go to Artist"),
icon: "artist",
};
const option5: Option = {
label: "Go to Album",
action: () => {
Router.push({
name: "AlbumView",
params: { album: track.album, artist: track.albumartist },
});
},
icon: "album",
};
const option6: Option = {
label: "Delete Track",
action: () => console.log("Delete Track"),
icon: "delete",
critical: true,
};
const separator: Option = {
type: "separator",
};
const options: Option[] = [
option1,
option2,
separator,
option3,
option4,
option5,
separator,
option6,
];
return options;
};