Skip to content

Commit

Permalink
[feature] speed-up alteri reposition by allowing double-click #45
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-rind committed Dec 3, 2021
1 parent 82ba20e commit c01d975
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/components/NetworkMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,31 @@ export default defineComponent({
});
});
let clickTimeoutId: number | null = null;
const clickAlter = (alter: Alter) => {
console.log(alter.name + " clicked");
if (isConnectMode.value && store.state.view.editIndex != null) {
const editId = store.state.nwk.alteri[store.state.view.editIndex].id;
const payload = { id1: editId, id2: alter.id };
store.commit("toggleConnection", payload);
} else {
// toggleSelection
store.commit("view/selectSingleAlter", alter.id);
if (clickTimeoutId == null) {
clickTimeoutId = setTimeout(() => {
// simple click
clickTimeoutId = null;
console.log(alter.name + " clicked");
// toggleSelection
store.commit("view/selectSingleAlter", alter.id);
}, 500); //tolerance in ms
} else {
// double click
clearTimeout(clickTimeoutId);
clickTimeoutId = null;
console.log(alter.name + " dblclick");
// open form
store.commit("openAlterFormById", { alterId: alter.id });
}
}
};
Expand Down
8 changes: 8 additions & 0 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ const mutations = {
state.view.editIndex = null;
state.view.editTab = "";
},
openAlterFormById(
state: IStoreState,
payload: { alterId: number; tab?: string }
): void {
const index = state.nwk.alteri.findIndex((a) => a.id === payload.alterId);
state.view.editIndex = index;
state.view.editTab = payload.tab ? payload.tab : TAB_BASE;
},
};

const plugins =
Expand Down

0 comments on commit c01d975

Please sign in to comment.