Skip to content

Commit

Permalink
Create composable for tracking a zoom level
Browse files Browse the repository at this point in the history
  • Loading branch information
phrasmotica committed Apr 27, 2024
1 parent 6adcbef commit f50f252
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/composables/useZoomLevel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useCycleList } from "@vueuse/core"
import { computed } from "vue"

export const useZoomLevel = () => {
const {
state: currentLevel,
next: zoomIn,
prev: zoomOut,
} = useCycleList([0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2], {
initialValue: 1,
})

const currentPercentage = computed(() => 100 * currentLevel.value)

return {
currentLevel,
currentPercentage,
zoomIn,
zoomOut,
}
}

0 comments on commit f50f252

Please sign in to comment.