@nanahoshi/mona-ui 0.18.1 → 0.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -285,7 +285,6 @@ class SegmentedComponent {
285
285
  afterNextRender({
286
286
  read: () => {
287
287
  this.setupResizeObserver();
288
- this.scheduleSettledGeometryUpdate();
289
288
  }
290
289
  });
291
290
  this.#destroyRef.onDestroy(() => {
@@ -328,22 +327,6 @@ class SegmentedComponent {
328
327
  }
329
328
  this.#observedOptionElements = elements;
330
329
  }
331
- /**
332
- * Guards against a stale indicator snapshot when the control mounts inside a container that is
333
- * still transitioning in (e.g. a popup's enter animation): the host's own box may not change once
334
- * that settles, so the ResizeObserver on it alone would never re-fire to correct the geometry.
335
- */
336
- scheduleSettledGeometryUpdate() {
337
- const win = this.#hostElementRef.nativeElement.ownerDocument.defaultView;
338
- if (!win) {
339
- return;
340
- }
341
- win.requestAnimationFrame(() => {
342
- win.requestAnimationFrame(() => {
343
- this.updateIndicatorGeometry({ suppressTransition: true });
344
- });
345
- });
346
- }
347
330
  setupResizeObserver() {
348
331
  if (typeof ResizeObserver === "undefined") {
349
332
  return;
@@ -370,14 +353,18 @@ class SegmentedComponent {
370
353
  this.indicatorTransitionEnabled.set(false);
371
354
  return;
372
355
  }
373
- const host = this.#hostElementRef.nativeElement;
374
356
  const option = selectedElementRef.nativeElement;
375
- const hostRect = host.getBoundingClientRect();
376
- const optionRect = option.getBoundingClientRect();
377
- const x = optionRect.left - hostRect.left - (host.clientLeft || 0);
378
- const y = optionRect.top - hostRect.top - (host.clientTop || 0);
379
- const width = optionRect.width;
380
- const height = optionRect.height;
357
+ // `offsetLeft`/`offsetTop`/`offsetWidth`/`offsetHeight` are pure layout values, relative to
358
+ // the nearest positioned ancestor (the host, which is `position: relative` and the option's
359
+ // direct parent). Unlike `getBoundingClientRect()`, they are unaffected by any CSS transform
360
+ // an ancestor applies — e.g. the scale animation `mona-popup` plays while opening. Measuring
361
+ // with `getBoundingClientRect()` there could capture a mid-transition (e.g. 95%-scaled)
362
+ // snapshot that never gets corrected once the animation settles, undersizing/misplacing the
363
+ // indicator relative to the option's real, final box.
364
+ const x = option.offsetLeft;
365
+ const y = option.offsetTop;
366
+ const width = option.offsetWidth;
367
+ const height = option.offsetHeight;
381
368
  const shouldAnimate = !options?.suppressTransition &&
382
369
  this.animate() &&
383
370
  this.indicatorInitialized() &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nanahoshi/mona-ui",
3
- "version": "0.18.1",
3
+ "version": "0.18.2",
4
4
  "description": "A very light Angular UI framework",
5
5
  "author": "Nanahoshi",
6
6
  "repository": {
@@ -149,12 +149,6 @@ declare class SegmentedComponent<T extends SegmentedValue = SegmentedValue> impl
149
149
  protected onOptionBlur(): void;
150
150
  protected onOptionChange(option: SegmentedOption<T>): void;
151
151
  private observeOptionElements;
152
- /**
153
- * Guards against a stale indicator snapshot when the control mounts inside a container that is
154
- * still transitioning in (e.g. a popup's enter animation): the host's own box may not change once
155
- * that settles, so the ResizeObserver on it alone would never re-fire to correct the geometry.
156
- */
157
- private scheduleSettledGeometryUpdate;
158
152
  private setupResizeObserver;
159
153
  private updateIndicatorGeometry;
160
154
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<SegmentedComponent<any>, never>;