Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

79
Views
Cambiando translateX después de setTimeout

Tengo un componente de tarjeta que el usuario puede mover hacia un lado para revelar botones.

Si el usuario no tocó ningún botón después de 2 segundos, quiero deslizar la tarjeta nuevamente a su lugar. Traté de lograr esto con setTimeout, pero aparece un error que dice que necesito usar runOnJS, lo intenté, pero obtuve el mismo error. Esto es lo que tengo:

 const panGesture = useAnimatedGestureHandler<PanGestureHandlerGestureEvent>({ onEnd: event => { const shouldStick = translateX.value >= TRANSLATE_X_THRESHOULD; if (shouldStick) { translateX.value = withTiming(120); setTimeout(() => { translateX.value = withTiming(0); }, 2000) } else { translateX.value = withTiming(0); } }, });

También intenté envolver setTimeout con runOnJS, así:

 runOnJS(() => { setTimeout(() => { translateX.value = withTiming(0); }, 2000); });

pero tampoco funcionó. ¿Es la forma correcta de lograr lo que estoy tratando de lograr?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!