-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Separate animation from transition (#45)
* Separate animation from transition * Separate config creation from class implementation * Add transitions registry to the manager, add null check * Changes after rebase
- Loading branch information
Showing
14 changed files
with
257 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 9 additions & 24 deletions
33
packages/react-native-reanimated/Common/cpp/reanimated/CSS/CSSTransition.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
packages/react-native-reanimated/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#pragma once | ||
|
||
#include <jsi/jsi.h> | ||
#include <string> | ||
|
||
using namespace facebook; | ||
|
||
namespace reanimated { | ||
|
||
struct CSSAnimationConfig { | ||
jsi::Object keyframeStyle; | ||
double animationDuration; | ||
jsi::Value animationTimingFunction; | ||
double animationDelay; | ||
double animationIterationCount; | ||
std::string animationDirection; | ||
std::string animationFillMode; | ||
}; | ||
|
||
inline jsi::Object getAnimationKeyframeStyle( | ||
jsi::Runtime &rt, | ||
const jsi::Object &config) { | ||
return config.getProperty(rt, "animationName").asObject(rt); | ||
} | ||
|
||
inline double getAnimationDuration( | ||
jsi::Runtime &rt, | ||
const jsi::Object &config) { | ||
return config.getProperty(rt, "animationDuration").asNumber(); | ||
} | ||
|
||
inline jsi::Value getAnimationTimingFunction( | ||
jsi::Runtime &rt, | ||
const jsi::Object &config) { | ||
return config.getProperty(rt, "animationTimingFunction"); | ||
} | ||
|
||
inline double getAnimationDelay(jsi::Runtime &rt, const jsi::Object &config) { | ||
return config.getProperty(rt, "animationDelay").asNumber(); | ||
} | ||
|
||
inline double getAnimationIterationCount( | ||
jsi::Runtime &rt, | ||
const jsi::Object &config) { | ||
return config.getProperty(rt, "animationIterationCount").asNumber(); | ||
} | ||
|
||
inline std::string getAnimationDirection( | ||
jsi::Runtime &rt, | ||
const jsi::Object &config) { | ||
return config.getProperty(rt, "animationDirection").asString(rt).utf8(rt); | ||
} | ||
|
||
inline std::string getAnimationFillMode( | ||
jsi::Runtime &rt, | ||
const jsi::Object &config) { | ||
return config.getProperty(rt, "animationFillMode").asString(rt).utf8(rt); | ||
} | ||
|
||
CSSAnimationConfig parseCSSAnimationConfig( | ||
jsi::Runtime &rt, | ||
const jsi::Value &config) { | ||
const auto &configObj = config.asObject(rt); | ||
|
||
return { | ||
std::move(getAnimationKeyframeStyle(rt, configObj)), | ||
getAnimationDuration(rt, configObj), | ||
std::move(getAnimationTimingFunction(rt, configObj)), | ||
getAnimationDelay(rt, configObj), | ||
getAnimationIterationCount(rt, configObj), | ||
getAnimationDirection(rt, configObj), | ||
getAnimationFillMode(rt, configObj)}; | ||
} | ||
|
||
} // namespace reanimated |
50 changes: 50 additions & 0 deletions
50
packages/react-native-reanimated/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#pragma once | ||
|
||
#include <jsi/jsi.h> | ||
#include <string> | ||
|
||
using namespace facebook; | ||
namespace reanimated { | ||
|
||
struct CSSTransitionConfig { | ||
jsi::Array transitionProperty; | ||
double transitionDuration; | ||
jsi::Value transitionTimingFunction; | ||
double transitionDelay; | ||
}; | ||
|
||
inline jsi::Array getTransitionProperty( | ||
jsi::Runtime &rt, | ||
const jsi::Object &config) { | ||
return config.getProperty(rt, "transitionProperty").asObject(rt).asArray(rt); | ||
} | ||
|
||
inline double getTransitionDuration( | ||
jsi::Runtime &rt, | ||
const jsi::Object &config) { | ||
return config.getProperty(rt, "transitionDuration").asNumber(); | ||
} | ||
|
||
inline jsi::Value getTransitionTimingFunction( | ||
jsi::Runtime &rt, | ||
const jsi::Object &config) { | ||
return config.getProperty(rt, "transitionTimingFunction"); | ||
} | ||
|
||
inline double getTransitionDelay(jsi::Runtime &rt, const jsi::Object &config) { | ||
return config.getProperty(rt, "transitionDelay").asNumber(); | ||
} | ||
|
||
CSSTransitionConfig parseCSSTransitionConfig( | ||
jsi::Runtime &rt, | ||
const jsi::Value &config) { | ||
const auto &configObj = config.asObject(rt); | ||
|
||
return CSSTransitionConfig{ | ||
getTransitionProperty(rt, configObj), | ||
getTransitionDuration(rt, configObj), | ||
getTransitionTimingFunction(rt, configObj), | ||
getTransitionDelay(rt, configObj)}; | ||
} | ||
|
||
} // namespace reanimated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.