Files
Schnappix/node_modules/react-native-reanimated/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.h
T

69 lines
2.1 KiB
C++

#pragma once
#include <reanimated/CSS/configs/CSSAnimationConfig.h>
#include <reanimated/CSS/configs/CSSKeyframesConfig.h>
#include <reanimated/CSS/easing/EasingFunctions.h>
#include <reanimated/CSS/progress/KeyframeProgressProvider.h>
#include <reanimated/CSS/progress/RawProgressProvider.h>
#include <memory>
namespace reanimated::css {
enum class AnimationProgressState {
Pending, // When the animation is waiting for the delay to pass
Running,
Paused,
Finished
};
class AnimationProgressProvider final : public KeyframeProgressProvider,
public RawProgressProvider {
public:
AnimationProgressProvider(
double timestamp,
double duration,
double delay,
double iterationCount,
AnimationDirection direction,
EasingFunction easingFunction,
const std::shared_ptr<KeyframeEasingFunctions> &keyframeEasingFunctions);
void setIterationCount(double iterationCount);
void setDirection(AnimationDirection direction);
void setEasingFunction(const EasingFunction &easingFunction);
AnimationDirection getDirection() const;
double getGlobalProgress() const override;
double getKeyframeProgress(double fromOffset, double toOffset) const override;
AnimationProgressState getState(double timestamp) const;
double getPauseTimestamp() const;
double getTotalPausedTime(double timestamp) const;
double getStartTimestamp(double timestamp) const;
void pause(double timestamp);
void play(double timestamp);
void resetProgress() override;
protected:
std::optional<double> calculateRawProgress(double timestamp) override;
private:
double iterationCount_;
AnimationDirection direction_;
EasingFunction easingFunction_;
std::shared_ptr<KeyframeEasingFunctions> keyframeEasingFunctions_;
unsigned currentIteration_ = 1;
double previousIterationsDuration_ = 0;
double pauseTimestamp_ = 0;
double totalPausedTime_ = 0;
bool shouldFinish(double timestamp) const;
double updateIterationProgress(double currentIterationElapsedTime);
double applyAnimationDirection(double iterationProgress) const;
};
} // namespace reanimated::css