Commit 806ea0c
authored
fix(tooltip): stop text blurring for ~150ms every time a tooltip appears (#6211)
* fix(tooltip): remove velocity skew/scale that blurred text on every appear
The tooltip animated a fractional scale() + skew() over 150ms on the element
containing its text. Chrome promotes the bubble to a compositor layer for the
transition, rasterizes the text once at the pre-transition scale, then
GPU-resamples that bitmap for the duration — so text rendered blurry until the
transition settled and the layer re-rasterized at 1:1.
It fired on every appear: a pointer entering a trigger is by definition moving,
so the first pointermove after pointerenter always set a non-zero skew and a
fractional scale.
- drop the velocity-reactive skew/scale flourish and the pointer-velocity
bookkeeping that existed only to feed it
- round tooltip position to whole pixels; clientX/clientY are fractional on
HiDPI/zoomed displays, leaving the bubble on a subpixel boundary
- drop the dead `filter` from the transition list — nothing ever set a filter
- skip the state update when the rounded position is unchanged, so pointer
jitter no longer re-renders every Tooltip.Trigger/Content consumer
The 150ms ease-out translate is kept, so the bubble still trails the cursor.
* improvement(tooltip): keep the velocity flourish, drive it without a CSS transition
Restores the velocity-reactive skew/scale removed in the previous commit. The
flourish was never the problem on its own — handing it to a CSS transition was.
An interpolated fractional scale makes the compositor rasterize the tooltip's
text once and resample that bitmap for the duration, which is what read as blur.
Applied as a static value per pointer event instead, so every frame is
rasterized at its own scale:
- split the transform across the individual `translate`, `scale`, and
`transform: skew()` properties, and transition only `translate` — position
still eases toward the cursor, the flourish no longer interpolates
- smooth the pointer velocity in JS (low-pass filter) to replace the smoothing
the CSS transition used to provide, so the squish still ramps rather than
snapping between raw per-event velocities
- quantize the flourish to 3 decimals so jitter below the visible threshold
settles instead of re-rendering every consumer
Whole-pixel position rounding and the redundant-update bail-out are unchanged.
* fix(tooltip): don't seed pointer velocity from the trigger box on focus
The previous commit routed `onFocus` through a shared reveal helper that seeds
`lastPointerRef` from the coordinates it is given. For focus those are the
trigger's box center, not the pointer — so if the pointer already happened to be
over the trigger, the next `pointermove` measured the box-to-cursor delta as
velocity and spiked the skew/scale flourish.
Split the helper in two: reveal-from-pointer seeds velocity tracking,
reveal-from-element leaves it cleared. Restores the pre-PR behavior, where focus
explicitly nulled the pointer snapshot.
Caught by Cursor Bugbot.
* fix(tooltip): make the flourish smoothing frame-rate independent
The velocity low-pass filter applied a fixed coefficient per pointer event, so
how fast the squish settled depended on how fast the device emitted events —
233ms at 30Hz down to 29ms at 240Hz, an 8x spread for the same gesture. It was
also far snappier than the 150ms CSS ease-out it replaced, so the flourish read
as twitchier than before.
Derive the coefficient from the real elapsed time instead
(1 - exp(-dt / tau), tau = 50ms). Settling is now flat at ~150ms from 60Hz
upward, matching the duration of the transition this stands in for.
Also separates the smoothing delta from the velocity-normalization delta: the
latter is still floored at one frame to keep a 1ms event from reporting an
enormous velocity, but flooring the former was itself a source of frame-rate
dependence below 16ms.
Verified against Chrome's documented re-raster behavior: a layer is re-rastered
at its new scale when the scale changes via script, but not when a declarative
animation interpolates it, which is why the flourish must stay out of the
transition list.
https://developer.chrome.com/blog/re-rastering-composite1 parent 6806fc2 commit 806ea0c
1 file changed
Lines changed: 109 additions & 42 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
17 | 31 | | |
18 | 32 | | |
19 | 33 | | |
| |||
27 | 41 | | |
28 | 42 | | |
29 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
30 | 53 | | |
31 | 54 | | |
32 | 55 | | |
| |||
50 | 73 | | |
51 | 74 | | |
52 | 75 | | |
53 | | - | |
54 | | - | |
55 | | - | |
| 76 | + | |
56 | 77 | | |
57 | 78 | | |
58 | 79 | | |
| |||
72 | 93 | | |
73 | 94 | | |
74 | 95 | | |
| 96 | + | |
75 | 97 | | |
76 | 98 | | |
77 | 99 | | |
78 | | - | |
| 100 | + | |
79 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
80 | 108 | | |
81 | 109 | | |
82 | 110 | | |
83 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
84 | 130 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
92 | 143 | | |
93 | 144 | | |
94 | 145 | | |
95 | 146 | | |
96 | 147 | | |
97 | | - | |
| 148 | + | |
98 | 149 | | |
99 | 150 | | |
100 | 151 | | |
101 | 152 | | |
102 | 153 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
107 | 167 | | |
108 | 168 | | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
115 | 173 | | |
116 | 174 | | |
117 | 175 | | |
| |||
121 | 179 | | |
122 | 180 | | |
123 | 181 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 182 | + | |
132 | 183 | | |
133 | 184 | | |
134 | 185 | | |
| |||
196 | 247 | | |
197 | 248 | | |
198 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
199 | 258 | | |
200 | 259 | | |
201 | 260 | | |
| |||
248 | 307 | | |
249 | 308 | | |
250 | 309 | | |
251 | | - | |
| 310 | + | |
252 | 311 | | |
253 | 312 | | |
254 | 313 | | |
255 | 314 | | |
256 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
257 | 318 | | |
258 | 319 | | |
259 | 320 | | |
| |||
268 | 329 | | |
269 | 330 | | |
270 | 331 | | |
271 | | - | |
| 332 | + | |
272 | 333 | | |
273 | 334 | | |
274 | 335 | | |
275 | 336 | | |
276 | 337 | | |
277 | 338 | | |
278 | | - | |
279 | | - | |
| 339 | + | |
| 340 | + | |
280 | 341 | | |
281 | 342 | | |
282 | 343 | | |
283 | 344 | | |
284 | 345 | | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
285 | 351 | | |
286 | | - | |
287 | | - | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
288 | 355 | | |
289 | | - | |
| 356 | + | |
290 | 357 | | |
291 | 358 | | |
292 | 359 | | |
| |||
0 commit comments