Skip to content

Commit 10fb3ff

Browse files
committed
test: test delta value by request #815
1 parent 170eaec commit 10fb3ff

File tree

4 files changed

+71
-1
lines changed

4 files changed

+71
-1
lines changed

packages/react-moveable/stories/7-Request/0-Request.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ export default {
66
};
77
export * from "./1-Draggable.stories";
88
export * from "./2-Resizable.stories";
9-
export * from "./3-ResizableGroup.stories";
9+
export * from "./3-ResizableDelta.stories";
10+
export * from "./4-ResizableGroup.stories";
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { DEFAULT_REACT_CODESANDBOX } from "storybook-addon-preview";
2+
import "../common.css";
3+
import "../templates/default.css";
4+
import { convertPath, convertReactTemplate, makeArgs } from "../utils";
5+
import App from "./apps/ResizableDeltaApp";
6+
import RawApp from "!!raw-loader!./apps/ResizableDeltaApp";
7+
import {
8+
DEFAULT_RESIZABLE_CONTROLS,
9+
} from "../controls/default";
10+
11+
12+
export const ResizableDeltaTemplate = App as any;
13+
14+
ResizableDeltaTemplate.storyName = "Resizable Delta";
15+
ResizableDeltaTemplate.argTypes = {
16+
...DEFAULT_RESIZABLE_CONTROLS,
17+
};
18+
ResizableDeltaTemplate.args = {
19+
...makeArgs(ResizableDeltaTemplate.argTypes),
20+
};
21+
22+
23+
ResizableDeltaTemplate.parameters = {
24+
preview: [
25+
{
26+
tab: "React",
27+
template: convertReactTemplate(convertPath(RawApp)),
28+
codesandbox: DEFAULT_REACT_CODESANDBOX(["react-moveable"]),
29+
language: "tsx",
30+
},
31+
],
32+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import * as React from "react";
2+
import Moveable, { ResizableRequestParam } from "@/react-moveable";
3+
4+
export default function App(props: Record<string, any>) {
5+
const moveableRef = React.useRef<Moveable>(null);
6+
7+
return <div className="root">
8+
<button onClick={() => {
9+
moveableRef.current!.request<ResizableRequestParam>("resizable", {
10+
deltaHeight: 12,
11+
}, true);
12+
}}>request</button>
13+
<div className="input"></div>
14+
<div className="container">
15+
<div className="target" style={{
16+
width: "381.609px",
17+
height: "119.416px",
18+
color: "black",
19+
marginTop: "20px",
20+
marginLeft: "20px",
21+
border: "none",
22+
}}>Target1</div>
23+
<Moveable
24+
ref={moveableRef}
25+
target={".target"}
26+
resizable={true}
27+
onResize={(e) => {
28+
e.target.style.width = `${e.width}px`;
29+
e.target.style.height = `${e.height}px`;
30+
const input = document.querySelector(".input")!;
31+
32+
input.innerHTML = JSON.stringify({ dist: e.dist, width: e.width, height: e.height });
33+
}}
34+
/>
35+
</div>
36+
</div>;
37+
}

0 commit comments

Comments
 (0)