Added scroll wheel navigation to yearly layout
This commit is contained in:
@@ -1,12 +1,31 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useCalendar } from '@/stores/CalendarStore'
|
import { useCalendar } from '@/stores/CalendarStore'
|
||||||
|
import { useThrottleFn } from '@vueuse/core'
|
||||||
|
|
||||||
import MonthTile from './MonthTile.vue'
|
import MonthTile from './MonthTile.vue'
|
||||||
|
|
||||||
const { staticConfig } = useCalendar()
|
const { staticConfig, decrementYear, incrementYear } = useCalendar()
|
||||||
|
|
||||||
|
function handleWheel(e: WheelEvent) {
|
||||||
|
const isMovingUp = e.deltaY < 0
|
||||||
|
if (isMovingUp) {
|
||||||
|
moveCalendarLeft()
|
||||||
|
} else {
|
||||||
|
moveCalendarRight()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const moveCalendarLeft = useThrottleFn(() => {
|
||||||
|
decrementYear()
|
||||||
|
}, 100)
|
||||||
|
|
||||||
|
const moveCalendarRight = useThrottleFn(() => {
|
||||||
|
incrementYear()
|
||||||
|
}, 100)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="container mt-[10vh] mb-auto">
|
<div class="container mt-[10vh] mb-auto" @wheel="handleWheel">
|
||||||
<div ref="test" class="grid grid-cols-5 gap-x-8 gap-y-16">
|
<div ref="test" class="grid grid-cols-5 gap-x-8 gap-y-16">
|
||||||
<MonthTile
|
<MonthTile
|
||||||
v-for="month in staticConfig.monthsPerYear"
|
v-for="month in staticConfig.monthsPerYear"
|
||||||
|
|||||||
Reference in New Issue
Block a user