Skip to content

Instantly share code, notes, and snippets.

@lintonye
Created January 19, 2019 23:36
Show Gist options
  • Save lintonye/b5ff783be891f5e3d234fbdf4e70972a to your computer and use it in GitHub Desktop.
Save lintonye/b5ff783be891f5e3d234fbdf4e70972a to your computer and use it in GitHub Desktop.
import { Data, animate, Override, Animatable } from "framer";
const data = Data({
button1Bg: Animatable("red"),
button2Bg: Animatable("white")
});
let activeButtonBg = data.button1Bg;
let inactiveButtonBg = data.button2Bg;
function toggleActiveButton() {
animate.ease(activeButtonBg, "white", { duration: 0.3 });
animate.ease(inactiveButtonBg, "red", { duration: 0.3 });
// swap buttons
const temp = activeButtonBg;
activeButtonBg = inactiveButtonBg;
inactiveButtonBg = temp;
}
export const Button1: Override = () => {
return {
background: data.button1Bg,
onTap() {
toggleActiveButton();
}
};
};
export const Button2: Override = () => {
return {
background: data.button2Bg,
onTap() {
toggleActiveButton();
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment