Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Renderer treats a sub-pixel width difference as a resize, which cancels the `motion()` entrance

Aperta Adatta ai principianti
#182 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
85/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript
Ambito
frontend

Direzione di ricerca

Individua la funzione responsiveSizeChanged nel codice del renderer dei grafici, dove il controllo di uguaglianza stretta next.width !== scene.width (e il suo equivalente in altezza) contrassegna erroneamente le differenze di sottopixel come ridimensionamenti. Aggiorna entrambi i confronti per ignorare le differenze inferiori a 0,5px, ad esempio usando Math.abs(next.width - scene.width) >= 0.5. Verifica la correzione renderizzando un Chart con renderer={motion()} in un contenitore con larghezza di pixel frazionaria per confermare che l'animazione di ingresso si completa invece di essere annullata da un render di ridimensionamento non necessario.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Version: @tanstack/charts 1.0.0 (unchanged on main).

The first render sizes the scene from getComputedStyle(container).width (contentBoxDimension → cssPixelValue). Chromium serializes that rounded, e.g. 569.594px. The ResizeObserver then reports the exact contentRect.width, 569.59375, and responsiveSizeChanged compares the two with !==:

next.width !== scene.width

So on any container with a fractional width (a 32% grid column, minmax(…)), the observer's first callback schedules a "resize" render. With motion()'s default resize: false, that render paints the final frame without animation, and the entrance is cancelled one frame after it starts. Containers that happen to be a whole number of pixels wide animate fine, so it looks random from the app side.

Repro: mount a Chart with renderer={motion()} inside <div style="width: 569.59375px">. data-ts-motion-state goes running, and the SVG is replaced on the first observer callback without ever reaching finished.

Suggested fix: treat a difference under half a pixel as no change (Math.abs(next.width - scene.width) >= 0.5, same for height), or take the first measurement from a source with the same precision as the observer. We're running the first as a pnpm patch, and it restores the entrance.

Lingua principale
TypeScript
Stelle
769
Fork
47
Merge medio
6h 9m
PR unite (30g)
20

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TanStack/charts

Tutte le issue di TanStack/charts

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.