Merge pull request #1073 from ciderapp/enhancement/playbackrate-slider-wheel

Implement wheel support for playback rate slider
This commit is contained in:
Amaru8 2022-05-23 20:12:36 +02:00 committed by GitHub
commit 10400e2799
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 9 deletions

View file

@ -15,7 +15,7 @@
{{playbackRate}} ×
</div>
<div class="md-option-segment md-option-segment_auto">
<input type="range" :step="0.05" min="0.25" :max="2" v-model="playbackRate">
<input type="range" :step="0.05" min="0.25" :max="2" @wheel="playbackRateWheel" v-model="playbackRate">
</div>
</div>
</div>
@ -34,10 +34,26 @@
},
watch: {
playbackRate: function (newValue, _oldValue) {
this.$root.mk.playbackRate = newValue
this.$root.cfg.audio.playbackRate = newValue
this.playbackRate = newValue
this.saveValue(newValue);
}
}
},
methods: {
playbackRateWheel(event) {
if (app.checkScrollDirectionIsUp(event)) {
this.saveValue(this.$root.cfg.audio.playbackRate + 0.05);
} else {
this.saveValue(this.$root.cfg.audio.playbackRate - 0.05);
}
},
saveValue(newValue) {
newValue = Number(newValue);
if (newValue >= 0.25 && newValue <= 2) {
newValue = String(newValue).length > 4 ? newValue.toFixed(2) : newValue;
this.$root.mk.playbackRate = newValue;
this.$root.cfg.audio.playbackRate = newValue;
this.playbackRate = newValue;
}
}
}
});
</script>
</script>