Skip to content

Commit

Permalink
修改一些细节
Browse files Browse the repository at this point in the history
  • Loading branch information
slince-zero committed Apr 29, 2024
1 parent 75c8cbf commit edc8caf
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
5 changes: 5 additions & 0 deletions READMECN.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,8 @@ const { boardTool, penSize } = useContext<ContextProp>(ImgContext)

当我将 `if (e.metaKey && e.key === 'z')` 改为 `if (e.key === 'command' || e.key === 'z')` 的时候,摁下 `Command + Z` 也会生效,我自己测试是这个键同时按下第二个代码才会生效,就很奇怪,这似乎违反了它的逻辑??


### 鼠标指针样式问题

一开始我以为是路径问题,发现控制台的网络请求可以正确看到指针的图片,最后发现是图片大小的问题。
在 Chrome、Firefox 和 Safari 中,自定义光标图像的最大高度和宽度都为 32px。如果你的图像超过这个限制,那么它只会显示为默认的光标。
1 change: 1 addition & 0 deletions public/pen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/rubber.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 11 additions & 12 deletions src/page/center/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@ export default function CenterBoard() {
}
}, [imgInfo])

// 设置鼠标样式-存在一些问题,不能正确显示
useEffect(() => {
const centerBoardElement = document.getElementsByClassName(
'img-area'
)[0] as HTMLElement
if (boardTool === 'pen') {
centerBoardElement.style.cursor = 'url(/assets/images/pen.svg),auto'
} else if (boardTool === 'rubber') {
centerBoardElement.style.cursor =
'url(/assets/images/rubber.svg),auto'
}
}, [boardTool])
// 设置鼠标样式-存在一些问题,现在可以正确显示了,不过存在精度问题,这里就不展示了
// useEffect(() => {
// const centerBoardElement = document.getElementsByClassName(
// 'img-area'
// )[0] as HTMLElement
// if (boardTool === 'pen') {
// centerBoardElement.style.cursor = 'url(/pen.svg),auto'
// } else if (boardTool === 'rubber') {
// centerBoardElement.style.cursor = 'url(/rubber.svg),auto'
// }
// }, [boardTool])

return (
<div
Expand Down

0 comments on commit edc8caf

Please sign in to comment.