Skip to content

Instantly share code, notes, and snippets.

@steveruizok
Last active July 19, 2019 16:25
Show Gist options
  • Select an option

  • Save steveruizok/5652a3d7c79f6a291409e840acd5e33a to your computer and use it in GitHub Desktop.

Select an option

Save steveruizok/5652a3d7c79f6a291409e840acd5e33a to your computer and use it in GitHub Desktop.
Page Navigation in Framer X.
import { Override } from "framer"
import { setCurrentPage } from "./Nav"
export function Page1Button(): Override {
return {
onTap: () => setCurrentPage(1)
}
}
export function Page2Button(): Override {
return {
onTap: () => setCurrentPage(2)
}
}
export function Page3Button(): Override {
return {
// Navigate after a one-second delay
onTap: () => setTimeout(() => setCurrentPage(3), 1000)
}
}
import { Override, Data } from "framer"
// Navigation ----------------
const navState = Data({
currentPage: 0,
})
// Functions ---
// Change the navigation's current page
export function setCurrentPage(index) {
const { currentPage } = navState
if (currentPage !== index) {
navState.currentPage = index
}
}
// Overrides ---
export function Page(): Override {
return {
currentPage: navState.currentPage,
onChangePage: index => setCurrentPage(index),
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment