mirror of
https://github.com/status-im/fathom.git
synced 2025-02-28 19:10:36 +00:00
set start variable outside of tick loop
This commit is contained in:
parent
9f6684f0fb
commit
fc552b0508
@ -32,10 +32,9 @@ class CountWidget extends Component {
|
||||
const setState = this.setState.bind(this);
|
||||
const startValue = isFinite(this.state.value) ? this.state.value : 0;
|
||||
const diff = toValue - startValue;
|
||||
let startTime;
|
||||
let startTime = performance.now();
|
||||
|
||||
const tick = function(t) {
|
||||
if(!startTime) { startTime = t; }
|
||||
let progress = ( t - startTime ) / duration;
|
||||
let newValue = startValue + (easeOutQuint(progress) * diff);
|
||||
setState({
|
||||
@ -46,7 +45,7 @@ class CountWidget extends Component {
|
||||
window.requestAnimationFrame(tick);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
window.requestAnimationFrame(tick);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user