修复时间线组件的pxPerFrame变量在setZoom函数调用前被修改导致setZoom函数失效的bug

This commit is contained in:
yueliuli 2026-04-24 10:44:41 +08:00
parent f4411ac5d3
commit 7f1c63aaf4
2 changed files with 5 additions and 3 deletions

View File

@ -101,10 +101,11 @@ export function useTimeline(
function setZoom(value: number): void { function setZoom(value: number): void {
const oldPxPerFrame = pxPerFrame.value const oldPxPerFrame = pxPerFrame.value
const newPxPerFrame = Math.max(minPxPerFrame.value, Math.min(value, maxPxPerFrame.value)) const newPxPerFrame = Math.max(minPxPerFrame.value, Math.min(maxPxPerFrame.value, value))
if (oldPxPerFrame === newPxPerFrame || !timelineContainer.value) if (oldPxPerFrame === newPxPerFrame || !timelineContainer.value) {
return return
}
const container = timelineContainer.value const container = timelineContainer.value
const containerWidth = container.clientWidth const containerWidth = container.clientWidth
@ -116,6 +117,7 @@ export function useTimeline(
&& playheadPosition <= containerScrollLeft + containerWidth && playheadPosition <= containerScrollLeft + containerWidth
// 计算缩放前后的位置偏移 // 计算缩放前后的位置偏移
// console.log('container.scrollLeft', container.scrollLeft)
if (playheadVisible) { if (playheadVisible) {
// 以播放头为中心缩放 // 以播放头为中心缩放
const playheadX = playheadPosition - containerScrollLeft const playheadX = playheadPosition - containerScrollLeft

View File

@ -64,7 +64,7 @@ onUnmounted(() => {
</el-text> </el-text>
</div> </div>
<ElSlider <ElSlider
v-model="pxPerFrame" :model-value="pxPerFrame"
:min="minPxPerFrame" :min="minPxPerFrame"
:max="maxPxPerFrame" :max="maxPxPerFrame"
:step="0.1" :step="0.1"