| 12 | * Corresponds to the DOM DOMRectReadOnly API. |
| 13 | */ |
| 14 | export class DOMRectReadOnlyPolyfill { |
| 15 | /** |
| 16 | * The x-coordinate of the rectangle. |
| 17 | */ |
| 18 | readonly x: number; |
| 19 | /** |
| 20 | * The y-coordinate of the rectangle. |
| 21 | */ |
| 22 | readonly y: number; |
| 23 | /** |
| 24 | * The width of the rectangle. |
| 25 | */ |
| 26 | readonly width: number; |
| 27 | /** |
| 28 | * The height of the rectangle. |
| 29 | */ |
| 30 | readonly height: number; |
| 31 | |
| 32 | /** |
| 33 | * Creates a new DOMRectReadOnly. |
| 34 | */ |
| 35 | constructor(x = 0, y = 0, width = 0, height = 0) { |
| 36 | this.x = x; |
| 37 | this.y = y; |
| 38 | this.width = width; |
| 39 | this.height = height; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * The top edge of the rectangle. |
| 44 | */ |
| 45 | get top(): number { |
| 46 | return this.height < 0 ? this.y + this.height : this.y; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * The right edge of the rectangle. |
| 51 | */ |
| 52 | get right(): number { |
| 53 | return this.width < 0 ? this.x : this.x + this.width; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * The bottom edge of the rectangle. |
| 58 | */ |
| 59 | get bottom(): number { |
| 60 | return this.height < 0 ? this.y : this.y + this.height; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * The left edge of the rectangle. |
| 65 | */ |
| 66 | get left(): number { |
| 67 | return this.width < 0 ? this.x + this.width : this.x; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Creates a DOMRectReadOnly from a DOMRectInit. |
nothing calls this directly
no outgoing calls
no test coverage detected