Skip to content

Commit 9054be0

Browse files
committed
demo: fix align demo #1045
1 parent fc9da03 commit 9054be0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export default function App() {
2020
y: rect.top,
2121
}, true);
2222
});
23+
24+
moveableRef.current?.updateRect();
2325
}}>Align Top</button>&nbsp;
2426
<button onClick={() => {
2527
const rect = moveableRef.current!.getRect();
@@ -33,6 +35,8 @@ export default function App() {
3335
y: rect.top + rect.height,
3436
}, true);
3537
});
38+
39+
moveableRef.current?.updateRect();
3640
}}>Align Bottom</button>&nbsp;
3741
<button onClick={() => {
3842
const rect = moveableRef.current!.getRect();
@@ -46,6 +50,8 @@ export default function App() {
4650
x: rect.left,
4751
}, true);
4852
});
53+
54+
moveableRef.current?.updateRect();
4955
}}>Align Left</button>&nbsp;
5056
<button onClick={() => {
5157
const rect = moveableRef.current!.getRect();
@@ -59,6 +65,8 @@ export default function App() {
5965
y: rect.left + rect.width,
6066
}, true);
6167
});
68+
69+
moveableRef.current?.updateRect();
6270
}}>Align Right</button>&nbsp;
6371
<button onClick={() => {
6472
const rect = moveableRef.current!.getRect();
@@ -72,6 +80,8 @@ export default function App() {
7280
y: rect.top + rect.height / 2 - rect.children![i].height / 2,
7381
}, true);
7482
});
83+
84+
moveableRef.current?.updateRect();
7585
}}>Align Vertical Center</button>&nbsp;
7686
<button onClick={() => {
7787
const rect = moveableRef.current!.getRect();
@@ -85,6 +95,8 @@ export default function App() {
8595
x: rect.left + rect.width / 2 - rect.children![i].width / 2,
8696
}, true);
8797
});
98+
99+
moveableRef.current?.updateRect();
88100
}}>Align Horizontal Center</button>&nbsp;
89101
<button onClick={() => {
90102
const groupRect = moveableRef.current!.getRect();
@@ -110,6 +122,9 @@ export default function App() {
110122

111123
top += rect.height + gap;
112124
});
125+
126+
127+
moveableRef.current?.updateRect();
113128
}}>Arrange Vertical Spacing</button>&nbsp;
114129
<button onClick={() => {
115130
const groupRect = moveableRef.current!.getRect();
@@ -135,6 +150,8 @@ export default function App() {
135150

136151
left += rect.width + gap;
137152
});
153+
154+
moveableRef.current?.updateRect();
138155
}}>Arrange Horizontal Spacing</button>&nbsp;
139156
<div className="target target1" style={{
140157
left: "50px",

0 commit comments

Comments
 (0)