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.

numericGestureControl stories

Sultan09624947037d
diff --git a/app/shared/design-system/components/primitives/numericGestureControl.js b/app/shared/design-system/components/primitives/numericGestureControl.js
index 972b675d90..a397ddc9ee 100644
--- a/app/shared/design-system/components/primitives/numericGestureControl.js
+++ b/app/shared/design-system/components/primitives/numericGestureControl.js
@@ -31,7 +31,7 @@ export const numericGestureControl = (
pointerId,
pressure,
}) => {
- const movement = direction === "horizontal" ? movementX : movementY;
+ const movement = direction === "horizontal" ? movementX : -movementY;
switch (type) {
case "pointerup": {
targetNode.releasePointerCapture(pointerId);
diff --git a/app/shared/design-system/components/primitives/numericGestureControl.stories.jsx b/app/shared/design-system/components/primitives/numericGestureControl.stories.jsx
new file mode 100644
index 0000000000..edd3218f0d
--- /dev/null
+++ b/app/shared/design-system/components/primitives/numericGestureControl.stories.jsx
@@ -0,0 +1,28 @@
+import {useRef, useEffect} from 'react';
+import {numericGestureControl} from './numericGestureControl.js';
+
+export default { title: 'numericGestureControl' };
+
+const useNumericGestureControl = ({ref, value, direction}) => {
+ useEffect(() => {
+ const {disconnectedCallback} = numericGestureControl(ref.current, {
+ initialValue: value,
+ direction: direction,
+ onValueChange: (event) => {
+ event.preventDefault();
+ event.target.value = event.value;
+ event.target.select();
+ }
+ });
+ return () => disconnectedCallback();
+ }, [direction]);
+}
+
+const Input = ({value, direction}) => {
+ const ref = useRef();
+ useNumericGestureControl({ref, value, direction});
+ return <input defaultValue={value} ref={ref} />;
+}
+
+export const Horizontal = () => <Input direction="horizontal" value={0} />;
+export const Vertical = () => <Input direction="vertical" value={0} />;