Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force regular cursor when leaving edit mode #903

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/components/WidgetHugger.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const initialWidgetPos = ref(props.widget.position)
const initialWidgetSize = ref(props.widget.size)

const handleDragStart = (event: MouseEvent): void => {
if (!allowMoving.value || isResizing.value || event.button !== 0 || !outerWidgetRef.value) return
if (!allowMoving.value || isResizing.value || !outerWidgetRef.value) return
draggingWidget.value = true
initialMousePos.value = { x: event.clientX, y: event.clientY }
initialWidgetPos.value = widget.value.position
Expand Down Expand Up @@ -234,6 +234,15 @@ onMounted(async () => {
document.addEventListener('mouseup', handleEnd)
})

// Change cursor when moving is allowed or disallowed, preventing the cursor to be a grab on exit of edit-mode
watch(allowMoving, (isAllowing, wasAllowing) => {
if (wasAllowing && !isAllowing) {
outerWidgetRef.value?.style.setProperty('cursor', 'default')
} else if (!wasAllowing && isAllowing) {
outerWidgetRef.value?.style.setProperty('cursor', 'grab')
}
})

const outerBounds = useElementBounding(outerWidgetRef)

const makeWidgetRespectWalls = (): void => {
Expand Down
Loading