Skip to content

Commit

Permalink
贴图 快捷键切换变换
Browse files Browse the repository at this point in the history
  • Loading branch information
xushengfeng committed Oct 23, 2024
1 parent e54d1f2 commit 68d7158
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/renderer/ding/ding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ const setNewDing = (
if (e.key === "Escape") {
close(wid);
}
if (!Number.isNaN(Number(e.key))) {
transform(div.el, Number(e.key) - 1);
}
});
div.add(toolBar).add(img);
document.querySelector("#photo").appendChild(div.el);
Expand Down Expand Up @@ -315,14 +318,14 @@ document.body.appendChild(tranStyle);
* 窗口变换
*/
function transform(el: HTMLElement, i: number) {
if (i >= 0) {
el.querySelector(".img").classList.add(`tran${i}`);
} else {
const l = Array.from(el.querySelector(".img").classList.values());
for (const t of l) {
if (t.startsWith("tran")) {
el.querySelector(".img").classList.remove(t);
}
const c = `tran${i}`;
if (i >= 0 && i < store.get("贴图.窗口.变换").length) {
el.querySelector(".img").classList.toggle(c);
}
const l = Array.from(el.querySelector(".img").classList.values());
for (const t of l) {
if (t.startsWith("tran") && t !== c) {
el.querySelector(".img").classList.remove(t);
}
}
}
Expand Down

0 comments on commit 68d7158

Please sign in to comment.