Skip to content

Instantly share code, notes, and snippets.

@yomete
Created November 7, 2017 16:22
Show Gist options
  • Save yomete/daba11e494f2fd7918917663ffafa534 to your computer and use it in GitHub Desktop.
Save yomete/daba11e494f2fd7918917663ffafa534 to your computer and use it in GitHub Desktop.
function mapStyles(styles) {
return {
opacity: styles.opacity,
transform: `scale(${styles.scale})`,
};
}
// wrap the `spring` helper to use a bouncy config
function bounce(val) {
return spring(val, {
stiffness: 330,
damping: 22,
});
}
// child matches will...
const bounceTransition = {
// start in a transparent, upscaled state
atEnter: {
opacity: 0,
scale: 1.2,
},
// leave in a transparent, downscaled state
atLeave: {
opacity: bounce(0),
scale: bounce(0.8),
},
// and rest at an opaque, normally-scaled state
atActive: {
opacity: bounce(1),
scale: bounce(1),
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment