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

Class Rect

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

Source from the content-addressed store, hash-verified

19 * Represents a rectangle.
20 */
21export class Rect {
22 /** The x-coordinate of the rectangle. */
23 x: number;
24
25 /** The y-coordinate of the rectangle. */
26 y: number;
27
28 /** The width of the rectangle. */
29 width: number;
30
31 /** The height of the rectangle. */
32 height: number;
33
34 constructor(x = 0, y = 0, width = 0, height = 0) {
35 this.x = x;
36 this.y = y;
37 this.width = width;
38 this.height = height;
39 }
40
41 /**
42 * The maximum x-coordinate in the rectangle.
43 */
44 get maxX(): number {
45 return this.x + this.width;
46 }
47
48 /**
49 * The maximum y-coordinate in the rectangle.
50 */
51 get maxY(): number {
52 return this.y + this.height;
53 }
54
55 /**
56 * The area of the rectangle.
57 */
58 get area(): number {
59 return this.width * this.height;
60 }
61
62 /**
63 * The top left corner of the rectangle.
64 */
65 get topLeft(): Point {
66 return new Point(this.x, this.y);
67 }
68
69 /**
70 * The top right corner of the rectangle.
71 */
72 get topRight(): Point {
73 return new Point(this.maxX, this.y);
74 }
75
76 /**
77 * The bottom left corner of the rectangle.
78 */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected