Implement changing year number. Added scroll support to numeric element.

This commit is contained in:
Leo Vasanko committed 2025-08-22 19:06:50 -06:00
1 parent 018b9ecc55
commit 271a41dd23
3 files changed
+88 -5

No files matched your search

+18
View File
@@ -12,6 +12,7 @@
tabindex="0"
@pointerdown="onPointerDown"
@keydown="onKey"
@wheel.prevent="onWheel"
>
<span class="value" :title="String(current)">{{ display }}</span>
</div>
@@ -217,6 +218,23 @@ function onKey(e) {
e.stopPropagation()
}
}
function onWheel(e) {
// Inverted: deltaY < 0 => decrement, > 0 => increment
const direction = e.deltaY < 0 ? -1 : e.deltaY > 0 ? 1 : 0
if (direction === 0) return
// Use current index in allValidValues list (prefix values included)
const idx = allValidValues.value.indexOf(current.value)
if (idx !== -1) {
const nextIdx = idx + direction
if (nextIdx >= 0 && nextIdx < allValidValues.value.length) {
current.value = allValidValues.value[nextIdx]
}
} else {
// Fallback numeric adjustment if not found
current.value = current.value + direction * props.step
}
}
</script>
<style scoped>