Skip to content

Commit

Permalink
Feature/merge nested styles (#1)
Browse files Browse the repository at this point in the history
* Merge nested styles and prefer animated
  • Loading branch information
SoHotSoup authored Sep 25, 2016
1 parent ac1c27c commit 2488498
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion connectAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -52,7 +62,7 @@ function resolveAnimatedStyle({

const animatedStyle = createAnimatedStyle(driver, { layout, animationOptions });

return _.assign(removeAnimationsFromStyle(style), animatedStyle);
return _.mergeWith(removeAnimationsFromStyle(style), animatedStyle, transferAnimatedValues);
}

/**
Expand Down

0 comments on commit 2488498

Please sign in to comment.