Detecting UI Overflow with Motion
Detecting overflow in moving UIs by using the bounding rectangles of frames with large displacement and images.
Languages
Table of Contents for This Article
When creating large UIs with animations, they may look great in still images, but elements spill out of the panel the moment they move. Diagonal color planes, bold text, bouncing motions. With this style, being "correct when stationary" is not enough. The times I repeatedly suffered in UI quality were due to this breakdown during motion.
Overflow Invisible in Still Images
As a result of the analysis, the overflow was both a layout bug and a lack in the verification method. Visual checks tend to focus on static frames, failing to observe the maximum reach of motion overshoot (temporary movement beyond the target). So, we established the criteria first. Even with motion overshoot, elements must remain within the parent panel. This is the passing line.
- Measurement TargetBounding Rectangles of Text and Buttons
- Measurement TimeSampling mid-motion to find the maximum point
- After FixingComparing the maximum value with the screen
The solution is to mechanize the containment check. We automatically determine whether the bounding rectangle of each element is contained within the parent panel, not only when static, but also at the phase of the motion's peak (maximum displacement). The human eye is lenient with "roughly contained," but numbers are not. Since the amount of overflow is output in pixel units, where and how to fix it are determined by calculation, not debate.
Sampling Mid-Motion
Extending this approach to a quality gate for the entire UI yields a set of measurable criteria. For example, in this prototype, we set 4.5 as the guideline for the contrast ratio between normal-sized text and the background. Buttons must have all 5 states: normal, hover, pressed, disabled, and selected. Theme coverage is 100%, ensuring no components remain uncolored after switching themes. Margins must fit the scale, with no ad-hoc values mixed in. All of these are items that can be mechanically judged as pass or fail, not based on impression.
There is a procedure for capturing the peak phase. We sample the motion frame by frame and record the "maximum amount of overflow from the parent panel" for each element. If the maximum value is 0 or less, it passes; elements with positive values are listed with their value and phase as a set. The fixer can see "when and how much it overflowed," speeding up decisions on whether to widen margins or reduce motion amplitude. Checking theme coverage follows the same method: scanning all screens in the state where the theme is switched to mechanically pick up components without theme colors. Visual inspection by human eyes comes last; the order is to finish mechanical checks first.
Cross-Referencing Numerical Values and Visuals
For elements that bounce horizontally and elements that rotate, the time when overflow is maximum is not necessarily the same. We capture not only position but also the bounding rectangle after rotation, retaining the maximum value and its time for each element. If there are decorations intentionally shown outside the panel, we limit the target scope to avoid confusing them with text or action buttons.
Verification involves checking the results that passed the gate alongside the screen. If the numbers pass but the screen looks poor, that is a discovery that the gate's items are insufficient, providing material for adding the next criteria. Conversely, items that fail numerically are targets for fixing without excuse.
The principle is one: Do not manage UI quality with "it feels good." Overflow, contrast, and missing states are measurable defects, not matters of sense. Make measurable things into gates, and fix what falls through the gates. The flashier the style, the more this unglamorous mechanism works.