Skip to content

Instantly share code, notes, and snippets.

@ibare
Last active January 1, 2019 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibare/91bb49c0fe98988a3b3347969abb3688 to your computer and use it in GitHub Desktop.
Save ibare/91bb49c0fe98988a3b3347969abb3688 to your computer and use it in GitHub Desktop.
FramerX KeepGrowing interaction
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