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

feat(Screen): allow to zoom and pan screenshare content #14028

Open
wants to merge 4 commits into
base: fix/12187/presenter-overlay-borders
Choose a base branch
from
Open
Show file tree
Hide file tree
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
72 changes: 72 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"lodash": "^4.17.21",
"mitt": "^3.0.1",
"mockconsole": "0.0.1",
"panzoom": "^9.4.3",
"pinia": "^2.3.0",
"ua-parser-js": "^2.0.0",
"util": "^0.12.5",
Expand Down
14 changes: 14 additions & 0 deletions src/components/CallView/CallView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<div id="videos">
<div v-if="devMode ? !isGrid : (!isGrid || !callParticipantModels.length)"
ref="videoPromotedWrapper"
class="video__promoted"
:class="{'full-page': showFullPage}">
<!-- Selected video override mode -->
Expand Down Expand Up @@ -73,6 +74,7 @@
@force-promote-video="forcePromotedModel = $event" />
<!-- presenter overlay -->
<PresenterOverlay v-if="shouldShowPresenterOverlay"
:key="promotedWrapperDimensions"
:token="token"
:model="presenterModel"
:shared-data="presenterSharedData"
Expand Down Expand Up @@ -237,6 +239,8 @@ export default {
showPresenterOverlay: true,
debounceFetchPeers: () => {},
forcePromotedModel: null,
resizeObserver: null,
promotedWrapperDimensions: null,
}
},

Expand Down Expand Up @@ -495,6 +499,9 @@ export default {

subscribe('switch-screen-to-id', this._switchScreenToId)
subscribe('set-background-blurred', this.setBackgroundBlurred)

this.resizeObserver = new ResizeObserver(this.updatePromotedWrapperDimensions)
this.resizeObserver.observe(this.$refs.videoPromotedWrapper)
},

beforeDestroy() {
Expand All @@ -506,6 +513,10 @@ export default {

unsubscribe('switch-screen-to-id', this._switchScreenToId)
unsubscribe('set-background-blurred', this.setBackgroundBlurred)

if (this.resizeObserver) {
this.resizeObserver.disconnect()
}
},

methods: {
Expand Down Expand Up @@ -800,6 +811,9 @@ export default {
}
},

updatePromotedWrapperDimensions([entry]) {
this.promotedWrapperDimensions = `${entry.contentRect.width}:${entry.contentRect.height}`
},
},
}
</script>
Expand Down
7 changes: 7 additions & 0 deletions src/components/CallView/shared/PresenterOverlay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<VueDraggableResizable v-if="!isCollapsed"
:key="presenterOverlaySize"
parent
class="presenter-overlay"
:resizable="false"
:h="presenterOverlaySize"
:w="presenterOverlaySize"
Expand Down Expand Up @@ -130,6 +131,12 @@ export default {
</script>

<style lang="scss" scoped>
.presenter-overlay {
position: absolute;
top: 0;
left: 0;
}

.presenter-overlay__video {
position: relative;
--max-size: 242px;
Expand Down
41 changes: 35 additions & 6 deletions src/components/CallView/shared/Screen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<script>
import Hex from 'crypto-js/enc-hex.js'
import SHA1 from 'crypto-js/sha1.js'
import panzoom from 'panzoom'
import { ref, onMounted, onBeforeUnmount } from 'vue'

import { t } from '@nextcloud/l10n'

Expand Down Expand Up @@ -64,7 +66,27 @@ export default {

setup() {
const guestNameStore = useGuestNameStore()
return { guestNameStore }

const screen = ref(null)
const screenPanzoomInstance = ref(null)

onMounted(() => {
screenPanzoomInstance.value = panzoom(screen.value, {
minZoom: 1,
maxZoom: 8,
bounds: true,
boundsPadding: 1,
})
})
onBeforeUnmount(() => {
screenPanzoomInstance.value?.dispose()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which case screenPanzoomInstance.value is null/undefined?

})

return {
guestNameStore,
screen,
screenPanzoomInstance,
}
},

computed: {
Expand Down Expand Up @@ -111,11 +133,10 @@ export default {
return remoteParticipantName
},
screenClass() {
if (this.isBig) {
return 'screen--fit'
} else {
return 'screen--fill'
}
return [
this.isBig ? 'screen--fit' : 'screen--fill',
this.screenPanzoomInstance ? 'screen--magnify' : '',
]
},

},
Expand Down Expand Up @@ -165,6 +186,11 @@ export default {

<style lang="scss" scoped>

.screenContainer {
width: 100%;
height: 100%;
}

.screen {
width: 100%;
height: 100%;
Expand All @@ -177,6 +203,9 @@ export default {
&--fill {
object-fit: cover;
}
&--magnify {
cursor: zoom-in;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zoom-in cursor stays even when the cursor is used to zoom-out or move the image.

}
}

</style>
Loading