[bug]: Translating values starting from 0 requires unit symbol

Aperta
#2,303 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à
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
react, typescript
Ambito
frontend

Direzione di ricerca

Inizia con la riproduzione di @react-spring/web nel CodeSandbox collegato e traccia come viene interpretato il valore di trasformazione quando un estremo è translateY(0) e l’altro include una percentuale. Verifica il comportamento sia per @react-spring/web sia per @react-spring/three, quindi aggiungi un test di regressione che dimostri che l’attivazione e la disattivazione del menu viene animata in modo fluido senza richiedere un’unità per zero.

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

Descrizione

area: core kind: bug
Which react-spring target are you using?
  • @react-spring/web
  • @react-spring/three
  • @react-spring/native
  • @react-spring/konva
  • @react-spring/zdog
What version of react-spring are you using?

9.7.3

What's Wrong?

I have a really simple toggled animation of a menu that initially is set to transform: translateY(-100%), when the state is change it slides into view at transform: translateY(0), when the state is then changed again the animation is skipped and the menu just disappears. I found this was due to not having a % unit symbol on the end, others have also found this same issue

To Reproduce
import React from "react";
import { useSpring, animated } from '@react-spring/web';

export default function Menu({ isMenuActive, data }) {
    const springs = useSpring({
        transform: isMenuActive ? `translateY(0%)` : `translateY(-100%)`,
    });

    return (
        <>
            <animated.div style={springs} className="menu-container">
               <p>Menu Items</p>
               <p>Menu Items</p>
               <p>Menu Items</p>
            </animated.div>
        </>
    );
}

Use this basic react hook to animate in the menu component.

Expected Behaviour

When the animation value start at 0 it should infer either the pixel or percentage value so it translates smoothly as it does in normal CSS.

Link to repo

https://codesandbox.io/s/kind-black-sgr767?file=/src/App.js

Lingua principale
TypeScript
Stelle
29.3k
Fork
1.2k
Merge medio
3g 15h
PR unite (30g)
17

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 pmndrs/react-spring

Tutte le issue di pmndrs/react-spring

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.