From 2488498b8edfd141b8f64f2c6f50fb024c98f198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vukovi=C4=87?= <3.14wee@gmail.com> Date: Sun, 25 Sep 2016 09:01:17 +0200 Subject: [PATCH] Feature/merge nested styles (#1) * Merge nested styles and prefer animated --- connectAnimation.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/connectAnimation.js b/connectAnimation.js index 2f76be0..cd20bf5 100644 --- a/connectAnimation.js +++ b/connectAnimation.js @@ -15,6 +15,16 @@ function removeAnimationsFromStyle(style) { return _.omitBy(style, (value, key) => _.isFunction(value) && _.endsWith(key, ANIMATION_SUFFIX)); } +/** + * This function transfers styles that are created by animated interpolations + * and it does that recursively because sometimes style is an object/array + * which contains styles created by animated interpolations + */ +function transferAnimatedValues(styleValue, animatedStyleValue, key) { + if(_.isFunction(animatedStyleValue.interpolate) || _.isUndefined(styleValue)) { + return animatedStyleValue; + } +} function resolveAnimatedStyle({ props, @@ -52,7 +62,7 @@ function resolveAnimatedStyle({ const animatedStyle = createAnimatedStyle(driver, { layout, animationOptions }); - return _.assign(removeAnimationsFromStyle(style), animatedStyle); + return _.mergeWith(removeAnimationsFromStyle(style), animatedStyle, transferAnimatedValues); } /**