Skip to content

Commit

Permalink
Add tooltip to playback speed icon
Browse files Browse the repository at this point in the history
  • Loading branch information
hvangeffen committed Jan 19, 2024
1 parent 451c6c9 commit af488f3
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/components/general/DateTimeSlider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
<div class="play-controls">
<v-menu offset="25" transition="fade-transition">
<template v-slot:activator="{ props }">
<v-btn
v-bind="props"
density="compact"
variant="text"
icon="mdi-play-speed"
/>
<v-btn v-bind="props" density="compact" variant="text" icon>
<v-icon>mdi-play-speed</v-icon>
<v-tooltip location="top" activator="parent">
<span>Playback speed</span>
</v-tooltip>
</v-btn>
</template>

<v-list class="pa-1">
Expand Down Expand Up @@ -131,7 +131,7 @@ const currentSpeed = ref(defaultSpeed)
const availableSpeeds = [0.5, 1, 2, 4]
const isPlaying = ref(false)
let playIntervalTimer: ReturnType<typeof setInterval> | null = null
let playTimeoutTimer: ReturnType<typeof setTimeout> | null = null
const doFollowNow = ref(props.doFollowNow)
let followNowIntervalTimer: ReturnType<typeof setInterval> | null = null
Expand Down Expand Up @@ -274,17 +274,14 @@ function togglePlay(): void {
function startPlay(): void {
isPlaying.value = true
stopFollowNow()
playIntervalTimer = setInterval(
play,
props.playInterval * (1 / currentSpeed.value),
)
play()
}
function stopPlay(): void {
isPlaying.value = false
if (playIntervalTimer) {
clearInterval(playIntervalTimer)
playIntervalTimer = null
if (playTimeoutTimer) {
clearTimeout(playTimeoutTimer)
playTimeoutTimer = null
}
}
Expand All @@ -293,6 +290,12 @@ function play(): void {
dateIndex.value = 0
}
increment(playIncrement)
if (isPlaying.value) {
playTimeoutTimer = setTimeout(
play,
props.playInterval * (1 / currentSpeed.value),
)
}
}
function stepBackward(): void {
Expand All @@ -315,10 +318,6 @@ function increment(step: number): void {
function setSpeed(speed: number) {
currentSpeed.value = speed
if (isPlaying.value) {
stopPlay()
startPlay()
}
}
function formatSpeed(speed: number) {
Expand Down

0 comments on commit af488f3

Please sign in to comment.