Skip to content

Commit e171333

Browse files
committed
refactor(ruler): split
1 parent 27acbdf commit e171333

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

app/components/ruler/Ruler.tsx

+10-8
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,21 @@ class RulerView extends React.Component<IRuler & IProps, IState> {
196196
}
197197

198198
private split = (direction: SplitDirection) => () => {
199-
const isHorizontal = direction === SplitDirection.HORIZONTAL;
200-
const newWidth = isHorizontal ? this.state.width : this.state.width / 2;
201-
const newHeight = isHorizontal ? this.state.height / 2 : this.state.height;
199+
const isSplitHorizontally = direction === SplitDirection.HORIZONTAL;
200+
const width = this.state.width * (isSplitHorizontally ? 1 : 0.5);
201+
const height = this.state.height * (isSplitHorizontally ? 0.5 : 1);
202+
const x = isSplitHorizontally ? this.state.x : this.state.x + width;
203+
const y = isSplitHorizontally ? this.state.y + height : this.state.y;
202204

203-
this.setState(resize(newWidth, newHeight), () => {
205+
this.setState(resize(width, height), () => {
204206
setPositionInDOM(this.el.current, this.state.x, this.state.y);
205207
this.props.split(
206208
direction,
207209
this.props.id,
208-
isHorizontal ? this.state.x : this.state.x + newWidth,
209-
isHorizontal ? this.state.y + newHeight : this.state.y,
210-
newWidth,
211-
newHeight,
210+
x,
211+
y,
212+
width,
213+
height,
212214
this.props.color
213215
);
214216
});

0 commit comments

Comments
 (0)