#pragma once #include #include #include #include #include #include #include #include namespace reanimated::css { enum class TransitionProgressState { Pending, Running, Finished }; class TransitionPropertyProgressProvider final : public KeyframeProgressProvider, public RawProgressProvider { public: TransitionPropertyProgressProvider( double timestamp, double duration, double delay, const EasingFunction &easingFunction); TransitionPropertyProgressProvider( double timestamp, double duration, double delay, const EasingFunction &easingFunction, double reversingShorteningFactor); double getGlobalProgress() const override; double getKeyframeProgress(double fromOffset, double toOffset) const override; double getRemainingDelay(double timestamp) const; double getReversingShorteningFactor() const; TransitionProgressState getState() const; protected: std::optional calculateRawProgress(double timestamp) override; private: EasingFunction easingFunction_; double reversingShorteningFactor_ = 1; double getElapsedTime(double timestamp) const; }; using TransitionPropertyProgressProviders = std::unordered_map< std::string, std::shared_ptr>; class TransitionProgressProvider final { public: TransitionProgressState getState() const; double getMinDelay(double timestamp) const; TransitionPropertyProgressProviders getPropertyProgressProviders() const; std::unordered_set getRemovedProperties() const; void discardFinishedProgressProviders(); void discardIrrelevantProgressProviders( const std::unordered_set &transitionPropertyNames); void runProgressProviders( double timestamp, const CSSTransitionPropertiesSettings &propertiesSettings, const PropertyNames &changedPropertyNames, const std::unordered_set &reversedPropertyNames); void update(double timestamp); private: TransitionPropertyProgressProviders propertyProgressProviders_; std::unordered_set removedProperties_; std::shared_ptr createReversingShorteningProgressProvider( double timestamp, const CSSTransitionPropertySettings &propertySettings, const TransitionPropertyProgressProvider &existingProgressProvider); }; } // namespace reanimated::css