Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Screen): change double-click behaviour for screenshare panzoom #14255

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions src/components/CallView/shared/Screen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
-->

<template>
<div :id="screenContainerId" class="screenContainer">
<div :id="screenContainerId"
class="screenContainer"
@dblclick.capture="onDoubleClick">
<video v-show="(localMediaModel && localMediaModel.attributes.localScreen) || (callParticipantModel && callParticipantModel.attributes.screen)"
ref="screen"
:disablePictureInPicture="!isBig ? 'true' : 'false'"
Expand Down Expand Up @@ -33,6 +35,10 @@ import VideoBottomBar from './VideoBottomBar.vue'
import { useGuestNameStore } from '../../../stores/guestName.js'
import attachMediaStream from '../../../utils/attachmediastream.js'

const ZOOM_MIN = 1
const ZOOM_FACTOR = 4
const ZOOM_MAX = 8

export default {

name: 'Screen',
Expand Down Expand Up @@ -88,8 +94,8 @@ export default {
onMounted(() => {
if (props.isBig) {
instance.value = panzoom(screen.value, {
minZoom: 1,
maxZoom: 8,
minZoom: ZOOM_MIN,
maxZoom: ZOOM_MAX,
bounds: true,
boundsPadding: 1,
})
Expand All @@ -108,10 +114,38 @@ export default {
instance.value?.dispose()
})

/**
* Overriding method to handle double click event on screen share
* @param event Double click event
*/
function onDoubleClick(event) {
if (!instance.value) {
return
}

// panzoom library puts a listener on parent element
event.preventDefault()
event.stopPropagation()

// Calculate the offset of the click event from the top left corner of screen container
const screenContainerRect = event.currentTarget.getBoundingClientRect()
const offsetX = event.clientX - screenContainerRect.left
const offsetY = event.clientY - screenContainerRect.top

if (instanceTransform.value.scale === 1) {
// Zoom in the click point with specified zoom factor
instance.value.smoothZoom(offsetX, offsetY, ZOOM_FACTOR)
} else {
// Zoom out (0 is set to ensure the zoom is reset to 1)
instance.value.smoothZoomAbs(offsetX, offsetY, 0)
}
}

return {
guestNameStore,
screen,
screenClass,
onDoubleClick,
}
},

Expand Down
Loading