Skip to content

Commit b0e199e

Browse files
committed
check two direction if axis is provided
1 parent 3638696 commit b0e199e

1 file changed

Lines changed: 37 additions & 15 deletions

File tree

packages/dflex-utils/src/Box/BoxNum.ts

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,47 +115,69 @@ class BoxNum extends Box<number> {
115115
preservedBoxResult.setBox(false, false, false, false);
116116
}
117117

118-
let checkTop: boolean = true;
119-
let checkBottom: boolean = true;
120-
121-
let checkRight: boolean = true;
122-
let checkLeft: boolean = true;
123-
124118
if (axis) {
125119
if (axis === "y") {
126-
checkRight = false;
127-
checkLeft = false;
128-
} else {
129-
checkTop = false;
130-
checkBottom = false;
120+
const isAbove = this._isAboveThresholdTop(threshold);
121+
const isBelow = this._isBelowThresholdBottom(threshold);
122+
123+
if (isAbove) {
124+
if (preservedBoxResult) {
125+
preservedBoxResult.top = true;
126+
}
127+
}
128+
129+
if (isBelow) {
130+
if (preservedBoxResult) {
131+
preservedBoxResult.bottom = true;
132+
}
133+
}
134+
135+
return isAbove || isBelow;
136+
}
137+
138+
const isLeft = this._isLeftOfThresholdLeft(threshold);
139+
const isRight = this._isRightOfThresholdRight(threshold);
140+
141+
if (isLeft) {
142+
if (preservedBoxResult) {
143+
preservedBoxResult.left = true;
144+
}
145+
}
146+
147+
if (isRight) {
148+
if (preservedBoxResult) {
149+
preservedBoxResult.right = true;
150+
}
131151
}
152+
153+
return isLeft || isRight;
132154
}
133155

134-
if (checkTop && this._isAboveThresholdTop(threshold)) {
156+
if (this._isAboveThresholdTop(threshold)) {
135157
if (preservedBoxResult) {
136158
preservedBoxResult.top = true;
137159
}
138160

139161
return true;
140162
}
141163

142-
if (checkRight && this._isRightOfThresholdRight(threshold)) {
164+
if (this._isRightOfThresholdRight(threshold)) {
143165
if (preservedBoxResult) {
144166
preservedBoxResult.right = true;
145167
}
146168

147169
return true;
148170
}
149171

150-
if (checkBottom && this._isBelowThresholdBottom(threshold)) {
172+
if (this._isBelowThresholdBottom(threshold)) {
151173
if (preservedBoxResult) {
152174
preservedBoxResult.bottom = true;
153175
}
154176

155177
return true;
156178
}
157179

158-
if (checkLeft && this._isLeftOfThresholdLeft(threshold)) {
180+
if (this._isLeftOfThresholdLeft(threshold)) {
159181
if (preservedBoxResult) {
160182
preservedBoxResult.left = true;
161183
}

0 commit comments

Comments
 (0)