Skip to content

Commit 3d0024b

Browse files
Merge pull request #2035 from frankrousseau/main
[players] Tighten panzoom and add scrub/focus shortcuts
2 parents 1ec0ba7 + ca1f7e3 commit 3d0024b

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/components/players/players/PreviewPlayer.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
:style="{
105105
opacity: overlayOpacity
106106
}"
107+
@panzoom-ready="onComparisonPanzoomReady"
107108
@video-loaded="onComparisonVideoLoaded"
108109
v-show="isComparing && previewToCompare"
109110
/>
@@ -1121,6 +1122,17 @@ const realignComparisonCanvas = () => {
11211122
loadComparisonAnnotationAtCurrentFrame()
11221123
}
11231124
1125+
// Push the main viewer's current transform onto the comparison
1126+
// viewer once its panzoom instance is (re)bound. The comparison
1127+
// binds lazily — on the media's load event after a revision swap —
1128+
// so the panzoomTransform watcher (which only fires on changes) had
1129+
// no chance to sync the fresh instance back to the main viewer.
1130+
const onComparisonPanzoomReady = () => {
1131+
if (!isComparing.value) return
1132+
const { x, y, scale } = panzoomTransform.value
1133+
comparisonViewer.value?.setPanZoom(x, y, scale)
1134+
}
1135+
11241136
const onComparisonVideoLoaded = () => {
11251137
syncComparisonViewer()
11261138
// The comparison canvas position and size are derived from the

src/components/players/viewers/PreviewViewer.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
@duration-changed="duration => $emit('duration-changed', duration)"
4545
@frame-update="frameNumber => $emit('frame-update', frameNumber)"
4646
@panzoom-changed="onVideoPanzoomChanged"
47+
@panzoom-ready="$emit('panzoom-ready')"
4748
@play-ended="$emit('play-ended')"
4849
@size-changed="onVideoSizeChanged"
4950
@video-end="$emit('video-end')"
@@ -63,6 +64,7 @@
6364
:preview="preview"
6465
@loaded="$emit('picture-loaded')"
6566
@panzoom-changed="onPicturePanzoomChanged"
67+
@panzoom-ready="$emit('panzoom-ready')"
6668
@size-changed="onPictureSizeChanged"
6769
v-show="isPicture"
6870
/>
@@ -229,6 +231,7 @@ const emit = defineEmits([
229231
'frame-update',
230232
'model-loaded',
231233
'panzoom-changed',
234+
'panzoom-ready',
232235
'picture-loaded',
233236
'play-ended',
234237
'size-changed',

src/components/players/viewers/VideoViewer.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ const emit = defineEmits([
120120
'duration-changed',
121121
'frame-update',
122122
'panzoom-changed',
123+
'panzoom-ready',
123124
'play-ended',
124125
'size-changed',
125126
'video-end',
@@ -440,6 +441,11 @@ const setupPanZoom = () => {
440441
panzoomInstance.on('zoom', emitPanZoom)
441442
panzoomInstance.on('pan', emitPanZoom)
442443
if (!panzoomActive) panzoomInstance.pause()
444+
// Tell the parent that a fresh instance exists so the comparison
445+
// sync can re-push the main viewer's transform — without this the
446+
// comparison stays at identity after a revision swap and drifts
447+
// out of sync with the main viewer.
448+
emit('panzoom-ready')
443449
}
444450
445451
const pausePanZoom = () => {

0 commit comments

Comments
 (0)