MCPcopy Create free account
hub / github.com/adobe/react-spectrum / intersection

Method intersection

packages/react-stately/src/virtualizer/Rect.ts:172–180  ·  view source on GitHub ↗

* Returns the intersection of this Rect with another. * If the rectangles do not intersect, an all zero Rect is returned.

(other: Rect)

Source from the content-addressed store, hash-verified

170 * If the rectangles do not intersect, an all zero Rect is returned.
171 */
172 intersection(other: Rect): Rect {
173 if (!this.intersects(other)) {
174 return new Rect(0, 0, 0, 0);
175 }
176
177 let x = Math.max(this.x, other.x);
178 let y = Math.max(this.y, other.y);
179 return new Rect(x, y, Math.min(this.maxX, other.maxX) - x, Math.min(this.maxY, other.maxY) - y);
180 }
181
182 /**
183 * Returns a copy of this rectangle.

Callers 10

buildRowMethod · 0.95
buildLoaderMethod · 0.95
buildRowGroupMethod · 0.80
buildLoaderMethod · 0.80
isValidMethod · 0.80
buildSectionMethod · 0.80
buildSectionHeaderMethod · 0.80
buildItemMethod · 0.80
updateLayoutNodeMethod · 0.80
getKeyRangeMethod · 0.80

Calls 1

intersectsMethod · 0.95

Tested by

no test coverage detected