File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
packages/core/useDraggable Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ export const UseDraggable = /* #__PURE__ */ defineComponent<UseDraggableProps>({
3535 'onMove' ,
3636 'onEnd' ,
3737 'disabled' ,
38+ 'buttons' ,
3839 ] as unknown as undefined ,
3940 setup ( props , { slots } ) {
4041 const target = ref ( )
Original file line number Diff line number Diff line change @@ -97,6 +97,20 @@ export interface UseDraggableOptions {
9797 * @default false
9898 */
9999 disabled ?: MaybeRefOrGetter < boolean >
100+
101+ /**
102+ * Mouse buttons that are allowed to trigger drag events.
103+ *
104+ * - `0`: Main button, usually the left button or the un-initialized state
105+ * - `1`: Auxiliary button, usually the wheel button or the middle button (if present)
106+ * - `2`: Secondary button, usually the right button
107+ * - `3`: Fourth button, typically the Browser Back button
108+ * - `4`: Fifth button, typically the Browser Forward button
109+ *
110+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button#value
111+ * @default [0]
112+ */
113+ buttons ?: MaybeRefOrGetter < number [ ] >
100114}
101115
102116/**
@@ -123,6 +137,7 @@ export function useDraggable(
123137 draggingElement = defaultWindow ,
124138 containerElement,
125139 handle : draggingHandle = target ,
140+ buttons = [ 0 ] ,
126141 } = options
127142
128143 const position = ref < Position > (
@@ -145,7 +160,7 @@ export function useDraggable(
145160 }
146161
147162 const start = ( e : PointerEvent ) => {
148- if ( e . button !== 0 )
163+ if ( ! toValue ( buttons ) . includes ( e . button ) )
149164 return
150165 if ( toValue ( options . disabled ) || ! filterEvent ( e ) )
151166 return
You can’t perform that action at this time.
0 commit comments