question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question. What is proper way of making delay of `startClock` ?

See original GitHub issue

I have a following logic

const restartAnimation = (
	) => [
		stopClock(clock),
		set(state.finished, 0),
		set(state.position, 0),
		set(state.time, 0),
		set(state.frameTime, 0),
		set(config.toValue, toValue),
		set(config.duration, duration),
		startClock(clock)
	];

return block([
   //somthing...
   timing(clock, state, config),
   cond(shouldRestartAnimation, [restartAnimation()]
  //something else
])

I want to delay startClock in restartAnimation. What is proper way of doing it with reanimated?

ps. thanks for great library

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jakub-gonetcommented, Nov 23, 2019

Hi @punksta,

this issue is quite old, so I’m closing it.

Solutions provided by @brmenchl and @satya164 should answer your question, additionally, you can try using delay from redash

If this doesn’t help, please comment.

1reaction
brmenchlcommented, Sep 10, 2019

Given a modified implementation of delay in https://github.com/kmagiera/react-native-reanimated/pull/71 that can be reset:

const delay = (clock, time, node, nodeBefore = 0, reset = new Value(0)) => {
  const when = new Value();
  return block([
    cond(or(not(defined(when)), reset), [
      set(when, add(clock, time)),
      set(reset, 0),
    ]),
    cond(greaterOrEq(clock, when), node, nodeBefore),
  ]);
}

const restartAnimation = () => [
  stopClock(clock),
  set(state.finished, 0),
  set(state.position, 0),
  set(state.time, 0),
  set(state.frameTime, 0),
  set(config.toValue, toValue),
  set(config.duration, duration),
  set(resetDelay, 1),
  startClock(clock)
];

return block([
   delay(clock, timing(clock, state, config), 0, reset),
   cond(shouldRestartAnimation, [restartAnimation()]
  //something else
])

I haven’t tested this, but it’s based on something that I have working in my app.

Read more comments on GitHub >

github_iconTop Results From Across the Web

implement time delay in c
By the way, this assumes time() returns a 1-second resolution value. ... #include <time.h> void delay(double dly){ /* save start clock tick ...
Read more >
Clock Question - The Huddle
Team A gets a false start, clock stops, ball is reset. ... It is a good way to eat clock if the other...
Read more >
How can I delay my period?
There's no guaranteed way to delay your period, but it may be possible if you take the combined contraceptive pill.
Read more >
Using the Delay Start Function of your Dishwasher
Delay Start button. If you would like to cancel and drain a cycle, press and hold the Start button for 3 seconds.
Read more >
Why Is My Period Late? 8 Possible Reasons
Cysts form on the ovaries as a result of this hormone imbalance. This can make ovulation irregular or stop it altogether. Other hormones,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found