mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 19:21:54 +03:00
291db8aa07
Fixes #10029 [Screencast from 2024-06-05 11-40-50.webm](https://github.com/enso-org/enso/assets/3919101/8dcb9099-5489-488c-86dc-560325e84f52)
40 lines
1.1 KiB
Vue
40 lines
1.1 KiB
Vue
<script setup lang="ts">
|
|
import { computed, ref, shallowRef } from 'vue'
|
|
|
|
import { usePointer } from '@/composables/events'
|
|
import { useNavigator } from '@/composables/navigator'
|
|
import type { Vec2 } from '@/util/data/vec2'
|
|
|
|
const viewportNode = ref<HTMLElement>()
|
|
|
|
const navigator = useNavigator(viewportNode)
|
|
|
|
const selectionAnchor = shallowRef<Vec2>()
|
|
|
|
const selection = usePointer((_, __, eventType) => {
|
|
if (selection.dragging && selectionAnchor.value == null) {
|
|
selectionAnchor.value = navigator.sceneMousePos?.copy()
|
|
} else if (eventType === 'stop') {
|
|
selectionAnchor.value = undefined
|
|
}
|
|
})
|
|
|
|
const scaledMousePos = computed(() => navigator.sceneMousePos?.scale(navigator.scale))
|
|
const scaledSelectionAnchor = computed(() => selectionAnchor.value?.scale(navigator.scale))
|
|
</script>
|
|
|
|
<template>
|
|
<div
|
|
ref="viewportNode"
|
|
style="cursor: none; height: 100%"
|
|
v-on.="navigator.pointerEvents"
|
|
v-on..="selection.events"
|
|
>
|
|
<slot
|
|
:scaledMousePos="scaledMousePos"
|
|
:scaledSelectionAnchor="scaledSelectionAnchor"
|
|
:navigator="navigator"
|
|
></slot>
|
|
</div>
|
|
</template>
|