Skip to content

Commit

Permalink
fix: web camera resize
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Apr 19, 2021
1 parent 69a2c97 commit 4bb8247
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/vite-slides/client/builtin/WebCamera.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ const frameStyle = computed(() => ({
const handleStyle = computed(() => ({
width: '14px',
height: '14px',
bottom: `${size.value / 2 * 0.3 - 7}px`,
right: `${size.value / 2 * 0.3 - 7}px`,
// 0.5 + 0.5 / sqrt(2)
top: `${size.value * 0.8536 - 7}px`,
left: `${size.value * 0.8536 - 7}px`,
cursor: 'nwse-resize',
}))
Expand Down Expand Up @@ -78,7 +79,7 @@ useEventListener(window, 'mousemove', (e: MouseEvent) => {
}
if (handlerDown.value && frame.value) {
const box = frame.value.getBoundingClientRect()
size.value = Math.max(10, Math.min(e.clientX - box.x, e.clientY - box.y))
size.value = Math.max(10, Math.min(e.clientX - box.x, e.clientY - box.y) / 0.8536)
}
})
Expand Down

0 comments on commit 4bb8247

Please sign in to comment.