From 19c81ec743ab4beccd6b964654d4cf818cfffabd Mon Sep 17 00:00:00 2001 From: AkiChase <1003019131@qq.com> Date: Tue, 30 Apr 2024 10:51:04 +0800 Subject: [PATCH] bug(KeyStringWheel): fix drag range --- src/components/keyboard/KeySteeringWheel.vue | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/keyboard/KeySteeringWheel.vue b/src/components/keyboard/KeySteeringWheel.vue index 026dabd..b937161 100644 --- a/src/components/keyboard/KeySteeringWheel.vue +++ b/src/components/keyboard/KeySteeringWheel.vue @@ -54,16 +54,16 @@ function dragHandler(downEvent: MouseEvent) { const keyboardElement = document.getElementById( "keyboardElement" ) as HTMLElement; - const maxX = keyboardElement.clientWidth - 40; - const maxY = keyboardElement.clientHeight - 40; + const maxX = keyboardElement.clientWidth - offset.value; + const maxY = keyboardElement.clientHeight - offset.value; const x = downEvent.clientX; const y = downEvent.clientY; const moveHandler = (moveEvent: MouseEvent) => { let newX = oldX + moveEvent.clientX - x; let newY = oldY + moveEvent.clientY - y; - newX = Math.max(0, Math.min(newX, maxX)); - newY = Math.max(0, Math.min(newY, maxY)); + newX = Math.max(offset.value, Math.min(newX, maxX)); + newY = Math.max(offset.value, Math.min(newY, maxY)); keyMapping.value.posX = newX; keyMapping.value.posY = newY; }; @@ -228,6 +228,7 @@ function showSetting() { .key-steering-wheel { position: absolute; border-radius: 50%; + box-sizing: border-box; border: 2px solid var(--blue-color); display: flex; justify-content: center;