use-elapsed-time
Advanced tools
Changelog
2.1.3 (May 29th, 2020)
Big fix:
useEffect
when environment is node
or window
is undefined. When the environment is browser useLayoutEffect
should be used insteaduseState
so React.StrictMode
doesn't bug the hook in developmentisPlaying
is set to false
when the duration is reachedChangelog
2.1.2 (May 18th, 2020)
Big fix:
startAt
valueChangelog
2.1.1 (May 13th, 2020)
Implemented enhancements:
autoResetKey
is a new prop that allows resetting the animation when the key changes. It works similar to React's key
propChangelog
2.0.1 (May 12th, 2020)
Bug fix:
Fix an issue where resetting the animation once it was done when the isPlaying
was set to true did not start playing after the reset
Changelog
2.0.0 (May 11th, 2020)
Breaking Changes:
elapsedTime
in seconds and reset
method, like so { elapsedTime, reset }
durationSeconds
is renamed to just duration
. The duration is now set in secondsstartAt
now expects value in secondsonComplete
will receive as an argument the totalElapsedTime
in seconds. The animation can now be repeated by returning an object instead of an array. The object may have the following params: shouldRepeat
indicates if the loop should start over; delay
- delay before looping again in seconds; newStartAt
set new start at value. |duration
while the loop is running will update the duration - if the new duration is more than the previous one, the measurement of the elapsed time will continue to the new duration; if the duration is less than the previous one, the onComplete
callback will be fired.Implemented enhancements:
options.shouldResetOnDurationChange
can be set to reset elapsed time when the duration changesreset
method, which can be used to reset the elapsed timeChangelog
1.1.5 (December 22nd, 2019)
Implemented enhancements:
Changelog
1.1.4 (December 19th, 2019)
Implemented enhancements: