Created
November 7, 2017 16:22
-
-
Save yomete/daba11e494f2fd7918917663ffafa534 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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