|
2 | 2 | <template> |
3 | 3 | <!-- TODO: Figure out keyboard accessibility... --> |
4 | 4 | <!-- eslint-disable-next-line vuejs-accessibility/click-events-have-key-events --> |
5 | | - <div ref="draggableContainer" id="draggable-container" @click="internalClick"> |
| 5 | + <div ref="draggableContainer" class="draggable-container" @click="internalClick"> |
6 | 6 | <div class="handle handle-l" @mousedown="resizeMouseDown($event, 'l')" /> |
7 | 7 | <div class="handle handle-tl" @mousedown="resizeMouseDown($event, 'tl')" /> |
8 | 8 | <div class="handle handle-t" @mousedown="resizeMouseDown($event, 't')" /> |
|
11 | 11 | <div class="handle handle-br" @mousedown="resizeMouseDown($event, 'br')" /> |
12 | 12 | <div class="handle handle-b" @mousedown="resizeMouseDown($event, 'b')" /> |
13 | 13 | <div class="handle handle-bl" @mousedown="resizeMouseDown($event, 'bl')" /> |
14 | | - <div id="draggable-header" @mousedown="dragMouseDown"> |
| 14 | + <div class="draggable-header" @mousedown="dragMouseDown"> |
15 | 15 | <slot name="header" /> |
16 | 16 | </div> |
17 | 17 | <slot name="main" /> |
|
21 | 21 |
|
22 | 22 | <script lang="ts" setup> |
23 | 23 | import gsap from 'gsap'; |
24 | | - import throttle from 'lodash/throttle'; |
25 | | - import { computed, onMounted, ref, watch } from 'vue'; |
| 24 | + import { throttle } from 'lodash'; |
| 25 | + import { computed, onMounted, reactive, ref, watch } from 'vue'; |
26 | 26 |
|
27 | 27 | const props = defineProps({ |
28 | 28 | enabled: { |
|
40 | 40 | (event: 'closeDragElement'): void; |
41 | 41 | }>(); |
42 | 42 |
|
43 | | - const positions = { |
| 43 | + const positions = reactive({ |
44 | 44 | clientX: 0, |
45 | 45 | clientY: 0, |
46 | 46 | movementX: 0, |
47 | 47 | movementY: 0, |
48 | | - }; |
49 | | - const resizePositions = { |
| 48 | + }); |
| 49 | + const resizePositions = reactive({ |
50 | 50 | clientX: 0, |
51 | 51 | clientY: 0, |
52 | 52 | movementX: 0, |
53 | 53 | movementY: 0, |
54 | 54 | dir: '', |
55 | | - }; |
| 55 | + }); |
56 | 56 |
|
57 | 57 | const draggableContainer = ref<HTMLDivElement>(); |
58 | 58 | /** |
|
300 | 300 | defineExpose({ minimize }); |
301 | 301 | </script> |
302 | 302 |
|
303 | | -<style> |
304 | | - #draggable-container { |
| 303 | +<style scoped> |
| 304 | + .draggable-container { |
305 | 305 | position: absolute; |
306 | 306 | z-index: 9; |
307 | 307 | } |
308 | | - #draggable-header { |
| 308 | + .draggable-header { |
309 | 309 | z-index: 10; |
310 | 310 | } |
311 | 311 |
|
|
0 commit comments