Skip to content

Commit 547f8fa

Browse files
authored
fix(useDraggable): add capture prop to component (#4911)
1 parent 4a249b4 commit 547f8fa

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

packages/core/useDraggable/component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const UseDraggable = /* #__PURE__ */ defineComponent<UseDraggableProps>({
3636
'disabled',
3737
'buttons',
3838
'containerElement',
39+
'capture',
3940
] as unknown as undefined,
4041
setup(props, { slots }) {
4142
const target = shallowRef<HTMLElement | SVGElement | null>()

packages/core/useDraggable/demo.vue

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,25 @@ const { x, y, style } = useDraggable(el, {
8787
I am at {{ Math.round(x) }}, {{ Math.round(y) }}
8888
</div>
8989
</Draggable>
90+
91+
<Draggable
92+
v-slot="{ x, y }"
93+
p="x-4 y-2"
94+
border="~ gray-400/30 rounded"
95+
shadow="~ hover:lg"
96+
class="fixed bg-$vp-c-bg select-none cursor-move z-31"
97+
:initial-value="{ x: innerWidth / 3.3, y: 330 }"
98+
prevent-default
99+
:disabled="disabled"
100+
:capture="false"
101+
>
102+
Not Use Captured Element
103+
<div class="text-xs opacity-50 cursor-default" @pointerdown.stop>
104+
Dragging here will not work
105+
</div>
106+
<div class="text-sm opacity-50">
107+
{{ Math.round(x) }}, {{ Math.round(y) }}
108+
</div>
109+
</Draggable>
90110
</div>
91111
</template>

0 commit comments

Comments
 (0)