Skip to content

Commit

Permalink
demo: fix align demo #1045
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Dec 3, 2023
1 parent fc9da03 commit 9054be0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/react-moveable/stories/7-Request/ReactAlignApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export default function App() {
y: rect.top,
}, true);
});

moveableRef.current?.updateRect();
}}>Align Top</button>&nbsp;
<button onClick={() => {
const rect = moveableRef.current!.getRect();
Expand All @@ -33,6 +35,8 @@ export default function App() {
y: rect.top + rect.height,
}, true);
});

moveableRef.current?.updateRect();
}}>Align Bottom</button>&nbsp;
<button onClick={() => {
const rect = moveableRef.current!.getRect();
Expand All @@ -46,6 +50,8 @@ export default function App() {
x: rect.left,
}, true);
});

moveableRef.current?.updateRect();
}}>Align Left</button>&nbsp;
<button onClick={() => {
const rect = moveableRef.current!.getRect();
Expand All @@ -59,6 +65,8 @@ export default function App() {
y: rect.left + rect.width,
}, true);
});

moveableRef.current?.updateRect();
}}>Align Right</button>&nbsp;
<button onClick={() => {
const rect = moveableRef.current!.getRect();
Expand All @@ -72,6 +80,8 @@ export default function App() {
y: rect.top + rect.height / 2 - rect.children![i].height / 2,
}, true);
});

moveableRef.current?.updateRect();
}}>Align Vertical Center</button>&nbsp;
<button onClick={() => {
const rect = moveableRef.current!.getRect();
Expand All @@ -85,6 +95,8 @@ export default function App() {
x: rect.left + rect.width / 2 - rect.children![i].width / 2,
}, true);
});

moveableRef.current?.updateRect();
}}>Align Horizontal Center</button>&nbsp;
<button onClick={() => {
const groupRect = moveableRef.current!.getRect();
Expand All @@ -110,6 +122,9 @@ export default function App() {

top += rect.height + gap;
});


moveableRef.current?.updateRect();
}}>Arrange Vertical Spacing</button>&nbsp;
<button onClick={() => {
const groupRect = moveableRef.current!.getRect();
Expand All @@ -135,6 +150,8 @@ export default function App() {

left += rect.width + gap;
});

moveableRef.current?.updateRect();
}}>Arrange Horizontal Spacing</button>&nbsp;
<div className="target target1" style={{
left: "50px",
Expand Down

0 comments on commit 9054be0

Please sign in to comment.