Last active
January 1, 2019 04:16
-
-
Save ibare/91bb49c0fe98988a3b3347969abb3688 to your computer and use it in GitHub Desktop.
FramerX KeepGrowing interaction
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
import { Data, animate, Override, Animatable } from "framer" | |
const STABLE_COLOR = '#FFF' | |
const GROWING_COLOR = '#F00' | |
let isGrowing = false | |
const data = Data({ | |
backgroundColor: Animatable(STABLE_COLOR), | |
likeScale: Animatable(1) | |
}) | |
const keepGrowing = () => { | |
if (isGrowing) { | |
if (data.likeScale.get() > 2) { | |
animate.ease(data.backgroundColor, GROWING_COLOR) | |
} | |
animate.ease(data.likeScale, data.likeScale.get() + 1) | |
} | |
} | |
export const KeepGrowingButton: Override = () => { | |
setInterval(keepGrowing, 100) | |
return { | |
scale: data.likeScale, | |
onTapStart() { | |
isGrowing = true | |
}, | |
onTapEnd() { | |
isGrowing = false | |
animate.spring(data.likeScale, 1) | |
animate.spring(data.backgroundColor, STABLE_COLOR) | |
} | |
} | |
} | |
export const BackgroundStatus: Override = () => { | |
return { | |
background: data.backgroundColor | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment