Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

refactor: Only use scrub distanceThreshold on inputs (#3226)

Oleg Isonen5bac838abbe0
diff --git a/apps/builder/app/builder/features/breakpoints/width-input.tsx b/apps/builder/app/builder/features/breakpoints/width-input.tsx
index f011c5a515..d1f650c3e1 100644
--- a/apps/builder/app/builder/features/breakpoints/width-input.tsx
+++ b/apps/builder/app/builder/features/breakpoints/width-input.tsx
@@ -45,6 +45,7 @@ const useEnhancedInput = ({
};
const { scrubRef, inputRef } = useScrub({
+ distanceThreshold: 2,
value,
onChange: handleChange,
onChangeComplete: handleChangeComplete,
diff --git a/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx b/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx
index 8d835a3df7..ccdbafaf98 100644
--- a/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx
+++ b/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx
@@ -159,6 +159,7 @@ const useScrub = ({
};
return numericScrubControl(scrubRefCurrent, {
+ distanceThreshold: 2,
getAcceleration() {
if (valueRef.current.type === "unit") {
return scrubUnitAcceleration.get(valueRef.current.unit);
diff --git a/packages/design-system/src/components/primitives/numeric-gesture-control.ts b/packages/design-system/src/components/primitives/numeric-gesture-control.ts
index f24e9c31a3..01cefed45b 100644
--- a/packages/design-system/src/components/primitives/numeric-gesture-control.ts
+++ b/packages/design-system/src/components/primitives/numeric-gesture-control.ts
@@ -78,7 +78,7 @@ export const numericScrubControl = (
onStart,
getValue = getValueDefault,
direction = "horizontal",
- distanceThreshold = 3,
+ distanceThreshold = 0,
onValueInput,
onValueChange,
onStatusChange,
diff --git a/packages/design-system/src/components/primitives/use-scrub.ts b/packages/design-system/src/components/primitives/use-scrub.ts
index 355a4d623a..3c70fe9f41 100644
--- a/packages/design-system/src/components/primitives/use-scrub.ts
+++ b/packages/design-system/src/components/primitives/use-scrub.ts
@@ -7,11 +7,13 @@ import { unstable_batchedUpdates as unstableBatchedUpdates } from "react-dom";
export const useScrub = ({
value,
+ distanceThreshold,
onChange,
onChangeComplete,
shouldHandleEvent,
}: {
value: NumericScrubValue;
+ distanceThreshold?: number;
onChange: (value: NumericScrubValue) => void;
onChangeComplete?: (value: NumericScrubValue) => void;
shouldHandleEvent?: (node: EventTarget) => boolean;
@@ -41,6 +43,7 @@ export const useScrub = ({
}
return numericScrubControl(scrubRefCurrent, {
+ distanceThreshold,
getInitialValue: () => {
return valueRef.current;
},
@@ -66,7 +69,7 @@ export const useScrub = ({
},
shouldHandleEvent: shouldHandleEventRef.current,
});
- }, []);
+ }, [distanceThreshold]);
return { scrubRef, inputRef };
};