Skip to content

fix(useDraggable): add capture prop to component #4911

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

Merged
merged 2 commits into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions packages/core/useDraggable/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const UseDraggable = /* #__PURE__ */ defineComponent<UseDraggableProps>({
'disabled',
'buttons',
'containerElement',
'capture',
] as unknown as undefined,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can actually drop this cast now i think

no action needed. feel free to do it in this PR, or don't and we can do it in a follow-up

setup(props, { slots }) {
const target = shallowRef<HTMLElement | SVGElement | null>()
Expand Down
20 changes: 20 additions & 0 deletions packages/core/useDraggable/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,25 @@ const { x, y, style } = useDraggable(el, {
I am at {{ Math.round(x) }}, {{ Math.round(y) }}
</div>
</Draggable>

<Draggable
v-slot="{ x, y }"
p="x-4 y-2"
border="~ gray-400/30 rounded"
shadow="~ hover:lg"
class="fixed bg-$vp-c-bg select-none cursor-move z-31"
:initial-value="{ x: innerWidth / 3.3, y: 330 }"
prevent-default
:disabled="disabled"
:capture="false"
>
Not Use Captured Element
<div class="text-xs opacity-50 cursor-default" @pointerdown.stop>
Dragging here will not work
</div>
<div class="text-sm opacity-50">
{{ Math.round(x) }}, {{ Math.round(y) }}
</div>
</Draggable>
</div>
</template>
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy