Skip to content

Commit

Permalink
feat: add preventDefault prop #821
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Mar 5, 2023
1 parent 172f6d4 commit b599e32
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/react-moveable/src/MoveableManager.tsx
Expand Up @@ -55,6 +55,7 @@ export default class MoveableManager<T = {}>
parentPosition: null,
portalContainer: null,
useResizeObserver: false,
preventDefault: true,
linePadding: 0,
controlPadding: 0,
ables: [],
Expand Down
1 change: 1 addition & 0 deletions packages/react-moveable/src/ables/Default.ts
Expand Up @@ -31,6 +31,7 @@ export default {
linePadding: Boolean,
displayAroundControls: Boolean,
controlPadding: Number,
preventDefault: Boolean,
} as const,
events: {
onChangeTargets: "changeTargets",
Expand Down
5 changes: 3 additions & 2 deletions packages/react-moveable/src/gesto/getAbleGesto.ts
Expand Up @@ -143,7 +143,7 @@ export function triggerAble(
able.unset && able.unset(moveable);
});
}
if (isStart && !isForceEnd && !isRequest && isUpdate) {
if (isStart && !isForceEnd && !isRequest && isUpdate && moveable.props.preventDefault) {
e?.preventDefault();
}
if (moveable.isUnmounted || isForceEnd) {
Expand Down Expand Up @@ -215,9 +215,10 @@ export function getAbleGesto(
preventClickEventOnDrag,
preventClickDefault,
checkInput,
preventDefault = true,
} = moveable.props;
const options: GestoOptions = {
preventDefault: true,
preventDefault,
preventRightClick: true,
preventWheelClick: true,
container: window,
Expand Down
6 changes: 6 additions & 0 deletions packages/react-moveable/src/types.ts
Expand Up @@ -156,6 +156,12 @@ export interface DefaultOptions {
* @default false
*/
stopPropagation?: boolean;
/**
* Whether to call preventDefault on touchstart or mousedown
* @since 0.44.0
* @default true
*/
preventDefault?: boolean;
/**
* Prevent click event on drag. (mousemove, touchmove)
* @default true
Expand Down

0 comments on commit b599e32

Please sign in to comment.