MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / computeOverflow

Function computeOverflow

packages/cli/src/utils/layoutAudit.ts:75–96  ·  view source on GitHub ↗
(
  subject: LayoutRect,
  container: LayoutRect,
  tolerance: number,
)

Source from the content-addressed store, hash-verified

73}
74
75export function computeOverflow(
76 subject: LayoutRect,
77 container: LayoutRect,
78 tolerance: number,
79): LayoutOverflow | null {
80 const overflow: LayoutOverflow = {};
81
82 if (subject.left < container.left - tolerance) {
83 overflow.left = roundPx(container.left - subject.left);
84 }
85 if (subject.right > container.right + tolerance) {
86 overflow.right = roundPx(subject.right - container.right);
87 }
88 if (subject.top < container.top - tolerance) {
89 overflow.top = roundPx(container.top - subject.top);
90 }
91 if (subject.bottom > container.bottom + tolerance) {
92 overflow.bottom = roundPx(subject.bottom - container.bottom);
93 }
94
95 return Object.keys(overflow).length > 0 ? overflow : null;
96}
97
98/**
99 * Whether a computed `overflow*` value clips its box. Mirrors the rule the

Callers 1

Calls 1

roundPxFunction · 0.85

Tested by

no test coverage detected