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

82
Views
Changing translateX after setTimeout

I have a card component that the user can move to the side to reveal buttons.

If the user didn't tap any button after 2 seconds, I want to slide the card back to place. I tried to achieve this with setTimeout, but I get an error that says I need to use runOnJS, I tried, but got the same error. This is what I have:

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);
      }
    },
  });

I also tried wrapping setTimeout with runOnJS, like this:

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

but it also didn't work. is it the right way to achieve what I'm trying to achieve?

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!