ui_migration fix(deps): --preliminary-- fixed replaced v-observe-visibility by vueuse useIntersectionObserver

This commit is contained in:
Antonio Anaya 2026-02-13 01:58:32 -06:00
parent 5825015aba
commit 5fe3d563f5
33 changed files with 154 additions and 80 deletions

View file

@ -2,7 +2,6 @@
<div <div
id="stream-display" id="stream-display"
ref="streamDisplay" ref="streamDisplay"
v-observe-visibility="visibilityChanged"
class="stream-display uk-width-1-1 uk-height-1-1 scrollTarget" class="stream-display uk-width-1-1 uk-height-1-1 scrollTarget"
> >
<img <img
@ -16,6 +15,9 @@
</template> </template>
<script> <script>
//vue3 migration
import { useIntersectionObserver } from '@vueuse/core';
// Export main app // Export main app
export default { export default {
name: "MiniStreamDisplay", name: "MiniStreamDisplay",
@ -31,10 +33,17 @@ export default {
return `${this.$store.getters.baseUri}/camera/mjpeg_stream`; return `${this.$store.getters.baseUri}/camera/mjpeg_stream`;
}, },
}, },
methods: {
visibilityChanged(isVisible) { mounted() {
this.isVisible = isVisible; useIntersectionObserver(
}, this.$refs.streamDisplay,
([{ isIntersecting }]) => {
this.isVisible = isIntersecting;
},
{
threshold: 0.0,
}
);
}, },
}; };
</script> </script>

View file

@ -1,6 +1,7 @@
<template> <template>
<div v-observe-visibility="visibilityChanged" class="uk-margin-remove uk-padding-remove"> <div class="uk-margin-remove uk-padding-remove">
<button <button
ref="actionButton"
type="button" type="button"
:disabled="buttonDisabled" :disabled="buttonDisabled"
class="uk-button uk-width-1-1 uk-position-relative" class="uk-button uk-width-1-1 uk-position-relative"
@ -28,8 +29,10 @@
<script> <script>
import ActionProgressBar from "./actionProgressBar.vue"; import ActionProgressBar from "./actionProgressBar.vue";
import ActionStatusModal from "./actionStatusModal.vue"; import ActionStatusModal from "./actionStatusModal.vue";
import { markRaw } from "vue"; //vue3 migration
import { eventBus } from "../../eventBus.js"; import { eventBus } from "../../eventBus.js";
import { useIntersectionObserver } from "@vueuse/core";
export default { export default {
name: "ActionButton", name: "ActionButton",
@ -155,20 +158,16 @@ export default {
handler(newval) { handler(newval) {
this.$emit("update:progress", newval); this.$emit("update:progress", newval);
}, },
//deep: true,
immediate: true // Optional: triggers immediately on component load
}, },
taskStarted: { taskStarted: {
handler(newval) { handler(newval) {
this.$emit("update:taskStarted", newval); this.$emit("update:taskStarted", newval);
}, },
//deep: true
}, },
taskRunning: { taskRunning: {
handler(newval) { handler(newval) {
this.$emit("update:taskRunning", newval); this.$emit("update:taskRunning", newval);
}, },
deep: true
}, },
log: { log: {
handler(newval) { handler(newval) {
@ -180,11 +179,20 @@ export default {
handler(newval) { handler(newval) {
this.$emit("update:taskStatus", newval); this.$emit("update:taskStatus", newval);
}, },
//deep: true
} }
}, },
mounted() { mounted() {
useIntersectionObserver(
this.$refs.actionButton,
([{ isIntersecting }]) => {
this.visibilityChanged(isIntersecting);
},
{
threshold: 0.0, // Adjust as needed
},
);
// Check for already running tasks // Check for already running tasks
if (this.taskStarted != true) { if (this.taskStarted != true) {
this.checkExistingTasks(); this.checkExistingTasks();

View file

@ -29,7 +29,6 @@ import UIkit from "uikit";
import ActionProgressBar from "./actionProgressBar.vue"; import ActionProgressBar from "./actionProgressBar.vue";
import ActionLogDisplay from "./actionLogDisplay.vue"; import ActionLogDisplay from "./actionLogDisplay.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
import { eventBus } from "../../eventBus.js"; import { eventBus } from "../../eventBus.js";
export default { export default {

View file

@ -101,7 +101,6 @@
<script> <script>
import syncPropertyButton from "./syncPropertyButton.vue"; import syncPropertyButton from "./syncPropertyButton.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
export default { export default {
name: "InputFromSchema", name: "InputFromSchema",
@ -216,13 +215,11 @@ export default {
this.updateIsEdited(); this.updateIsEdited();
this.resetInternalValue(); this.resetInternalValue();
}, },
//deep: true,
}, },
internalValue: { internalValue: {
handler() { handler() {
this.updateIsEdited(); this.updateIsEdited();
}, },
//deep: true,
}, },
animate(updated) { animate(updated) {
if (updated) { if (updated) {

View file

@ -14,7 +14,7 @@
import { formatValue } from "@/js_utils/formatter.mjs"; import { formatValue } from "@/js_utils/formatter.mjs";
import InputFromSchema from "./inputFromSchema.vue"; import InputFromSchema from "./inputFromSchema.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
export default { export default {
name: "PropertyControl", name: "PropertyControl",

View file

@ -18,7 +18,6 @@
<script> <script>
import ActionButton from "./actionButton.vue"; import ActionButton from "./actionButton.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
// Export main app // Export main app
export default { export default {

View file

@ -12,7 +12,6 @@
<script> <script>
import PropertyControl from "./propertyControl.vue"; import PropertyControl from "./propertyControl.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
// Export main app // Export main app
export default { export default {

View file

@ -28,7 +28,13 @@ import finalStep from "./calibrationWizardComponents/finalStep.vue";
export default { export default {
name: "CalibrationWizard", name: "CalibrationWizard",
components: {}, components: {
singleStepTask,
welcomeStep,
cameraCalibrationTask,
cameraStageMappingTask,
finalStep
},
data: function () { data: function () {
return { return {

View file

@ -20,7 +20,6 @@
import stepTemplateWithStream from "../stepTemplateWithStream.vue"; import stepTemplateWithStream from "../stepTemplateWithStream.vue";
import cameraCalibrationSettings from "../../../tabContentComponents/settingsComponents/cameraSettingsComponents/cameraCalibrationSettings.vue"; import cameraCalibrationSettings from "../../../tabContentComponents/settingsComponents/cameraSettingsComponents/cameraCalibrationSettings.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
export default { export default {
name: "CameraMainCalibrationStep", name: "CameraMainCalibrationStep",

View file

@ -31,7 +31,6 @@
import stepTemplateWithStream from "../stepTemplateWithStream.vue"; import stepTemplateWithStream from "../stepTemplateWithStream.vue";
import ActionButton from "../../../labThingsComponents/actionButton.vue"; import ActionButton from "../../../labThingsComponents/actionButton.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
export default { export default {
name: "CameraMainCalibrationStep", name: "CameraMainCalibrationStep",

View file

@ -19,7 +19,6 @@
import stepTemplateWithStream from "../stepTemplateWithStream.vue"; import stepTemplateWithStream from "../stepTemplateWithStream.vue";
import CSMCalibrationSettings from "../../../tabContentComponents/settingsComponents/CSMSettingsComponents/CSMCalibrationSettings.vue"; import CSMCalibrationSettings from "../../../tabContentComponents/settingsComponents/CSMSettingsComponents/CSMCalibrationSettings.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
export default { export default {
name: "CameraMainCalibrationStep", name: "CameraMainCalibrationStep",

View file

@ -9,7 +9,6 @@
<script> <script>
import miniStreamDisplay from "../../genericComponents/miniStreamDisplay.vue"; import miniStreamDisplay from "../../genericComponents/miniStreamDisplay.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
export default { export default {
name: "StepTemplateWithStream", name: "StepTemplateWithStream",

View file

@ -58,7 +58,6 @@
<script> <script>
import ActionButton from "../../labThingsComponents/actionButton.vue"; import ActionButton from "../../labThingsComponents/actionButton.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
export default { export default {
name: "StatusPane", name: "StatusPane",

View file

@ -25,7 +25,6 @@
import devTools from "./aboutComponents/devTools.vue"; import devTools from "./aboutComponents/devTools.vue";
import statusPane from "./aboutComponents/statusPane.vue"; import statusPane from "./aboutComponents/statusPane.vue";
//vue3 migration //vue3 migration
import { markRaw } from "vue";
export default { export default {
name: "AboutContent", name: "AboutContent",

View file

@ -1,5 +1,5 @@
<template> <template>
<div v-observe-visibility="visibilityChanged" class="uk-padding-small"> <div ref="backgroundDetectContent" class="uk-padding-small">
<div> <div>
<ul uk-accordion="multiple: true"> <ul uk-accordion="multiple: true">
<li> <li>
@ -48,7 +48,7 @@
import ActionButton from "../../labThingsComponents/actionButton.vue"; import ActionButton from "../../labThingsComponents/actionButton.vue";
import ServerSpecifiedPropertyControl from "../../labThingsComponents/serverSpecifiedPropertyControl.vue"; import ServerSpecifiedPropertyControl from "../../labThingsComponents/serverSpecifiedPropertyControl.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue"; import { useIntersectionObserver } from "@vueuse/core";
export default { export default {
components: { components: {
@ -107,6 +107,18 @@ export default {
} }
}, },
}, },
mounted() {
useIntersectionObserver(
this.$refs.backgroundDetectContent,
([{ isIntersecting }]) => {
this.visibilityChanged(isIntersecting);
},
{
threshold: 0.0,
},
);
},
}; };
</script> </script>
<style scoped lang="less"> <style scoped lang="less">

View file

@ -14,7 +14,6 @@
import paneBackgroundDetect from "./backgroundDetectComponents/paneBackgroundDetect"; import paneBackgroundDetect from "./backgroundDetectComponents/paneBackgroundDetect";
import streamDisplay from "./streamContent.vue"; import streamDisplay from "./streamContent.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
export default { export default {
name: "BackgroundDetectContent", name: "BackgroundDetectContent",

View file

@ -19,7 +19,6 @@
<script> <script>
import ActionButton from "../../labThingsComponents/actionButton.vue"; import ActionButton from "../../labThingsComponents/actionButton.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
import { eventBus } from "../../../eventBus.js"; import { eventBus } from "../../../eventBus.js";
export default { export default {

View file

@ -35,7 +35,6 @@ import ActionButton from "../../labThingsComponents/actionButton.vue";
import positionControl from "./positionControl.vue"; import positionControl from "./positionControl.vue";
import autofocusControl from "./autofocusControl.vue"; import autofocusControl from "./autofocusControl.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
export default { export default {
name: "PaneControl", name: "PaneControl",

View file

@ -62,7 +62,6 @@ import ActionButton from "../../labThingsComponents/actionButton.vue";
import syncPropertyButton from "../../labThingsComponents/syncPropertyButton.vue"; import syncPropertyButton from "../../labThingsComponents/syncPropertyButton.vue";
import stageControlButtons from "./stageControlButtons.vue"; import stageControlButtons from "./stageControlButtons.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
import { eventBus } from "../../../eventBus.js"; import { eventBus } from "../../../eventBus.js";
export default { export default {

View file

@ -14,7 +14,6 @@
import paneControl from "./controlComponents/paneControl.vue"; import paneControl from "./controlComponents/paneControl.vue";
import streamDisplay from "./streamContent.vue"; import streamDisplay from "./streamContent.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
export default { export default {
name: "ControlContent", name: "ControlContent",

View file

@ -1,5 +1,5 @@
<template> <template>
<div v-observe-visibility="visibilityChanged" class="uk-padding uk-padding-remove-top"> <div ref="loggingDisplay" class="uk-padding uk-padding-remove-top">
<!-- Logging nav bar --> <!-- Logging nav bar -->
<nav class="logging-navbar uk-navbar-container uk-navbar-transparent" uk-navbar="mode: click"> <nav class="logging-navbar uk-navbar-container uk-navbar-transparent" uk-navbar="mode: click">
<!-- Left side controls --> <!-- Left side controls -->
@ -84,7 +84,7 @@ import axios from "axios";
import Paginate from "vuejs-paginate"; import Paginate from "vuejs-paginate";
import EndpointButton from "../labThingsComponents/endpointButton.vue"; import EndpointButton from "../labThingsComponents/endpointButton.vue";
//vue3 migration //vue3 migration
import { markRaw } from "vue"; import { useIntersectionObserver } from "@vueuse/core";
export default { export default {
name: "LoggingContent", name: "LoggingContent",
@ -135,6 +135,18 @@ export default {
}, },
}, },
mounted() {
useIntersectionObserver(
this.$refs.loggingDisplay,
([{ isIntersecting }]) => {
this.visibilityChanged(isIntersecting);
},
{
threshold: 0.0,
},
);
},
methods: { methods: {
scrollToTop() { scrollToTop() {
this.$emit("scrollTop"); this.$emit("scrollTop");

View file

@ -1,11 +1,13 @@
<template> <template>
<div v-observe-visibility="visibilityChanged"> <div ref="osdViewerContainer" class="osd-viewer-container uk-height-1-1">
<div id="openseadragon" ref="osdContainer"></div> <div id="openseadragon" ref="osdContainer"></div>
</div> </div>
</template> </template>
<script> <script>
import OpenSeaDragon from "openseadragon"; import OpenSeaDragon from "openseadragon";
// vue3 migration
import { useIntersectionObserver } from "@vueuse/core";
export default { export default {
name: "OpenSeadragonViewer", name: "OpenSeadragonViewer",
@ -37,7 +39,6 @@ export default {
watch: { watch: {
src: { src: {
deep: true,
immediate: true, immediate: true,
handler(newVal) { handler(newVal) {
this.loadOpenSeaDragon(newVal); this.loadOpenSeaDragon(newVal);
@ -55,6 +56,14 @@ export default {
}, },
async mounted() { async mounted() {
useIntersectionObserver(
this.$refs.osdViewerContainer,
([{ isIntersecting }]) => {
this.visibilityChanged(isIntersecting);
},
{ threshold: 0.0 }
);
if (this.src) { if (this.src) {
this.loadOpenSeaDragon(this.src); this.loadOpenSeaDragon(this.src);
} }
@ -62,17 +71,28 @@ export default {
beforeUnmount() { beforeUnmount() {
// Remove global signal listener to perform a gallery refresh // Remove global signal listener to perform a gallery refresh
this.osdViewer.destroy(); if (this.osdViewer) {
this.osdViewer.destroy();
}
}, },
methods: { methods: {
visibilityChanged(isVisible) { visibilityChanged(isVisible) {
// adding this check to avoid error when the viewer is not yet initialized.
if (isVisible) { if (isVisible) {
this.loadOpenSeaDragon();
if (!this.osdViewer && this.src) {
this.loadOpenSeaDragon(this.src);
}
} else { } else {
this.osdViewer.destroy();
if (this.osdViewer) {
this.osdViewer.destroy();
this.osdViewer = null;
}
} }
}, },
async loadOpenSeaDragon() { async loadOpenSeaDragon() {
if (this.osdViewer) { if (this.osdViewer) {
this.osdViewer.destroy(); this.osdViewer.destroy();

View file

@ -83,7 +83,6 @@ import axios from "axios";
import actionButton from "../../labThingsComponents/actionButton.vue"; import actionButton from "../../labThingsComponents/actionButton.vue";
import EndpointButton from "../../labThingsComponents/endpointButton.vue"; import EndpointButton from "../../labThingsComponents/endpointButton.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
// Export main app // Export main app
export default { export default {

View file

@ -56,7 +56,6 @@
import UIkit from "uikit"; import UIkit from "uikit";
import OpenSeadragonViewer from "./openSeadragonViewer.vue"; import OpenSeadragonViewer from "./openSeadragonViewer.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
export default { export default {
name: "ScanViewerModal", name: "ScanViewerModal",

View file

@ -1,6 +1,6 @@
<template> <template>
<div <div
v-observe-visibility="visibilityChanged" ref="galleryDisplay"
class="galleryDisplay uk-padding uk-padding-remove-top" class="galleryDisplay uk-padding uk-padding-remove-top"
> >
<!-- Gallery nav bar --> <!-- Gallery nav bar -->
@ -101,8 +101,8 @@ import actionButton from "../labThingsComponents/actionButton.vue";
import scanCard from "./scanListComponents/scanCard.vue"; import scanCard from "./scanListComponents/scanCard.vue";
import ScanViewerModal from "./scanListComponents/scanViewer.vue"; import ScanViewerModal from "./scanListComponents/scanViewer.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
import { eventBus } from "../../eventBus.js"; import { eventBus } from "../../eventBus.js";
import { useIntersectionObserver } from "@vueuse/core";
// Export main app // Export main app
export default { export default {
@ -148,6 +148,15 @@ export default {
}, },
async mounted() { async mounted() {
useIntersectionObserver(
this.$refs.galleryDisplay,
([{ isIntersecting }]) => {
this.visibilityChanged(isIntersecting);
},
{
threshold: 0.0, // Adjust as needed
},
);
// Update on mount (does nothing if not connected) // Update on mount (does nothing if not connected)
await this.updateScans(); await this.updateScans();
// A global signal listener to perform a gallery refresh // A global signal listener to perform a gallery refresh

View file

@ -18,7 +18,6 @@
import CSMCalibrationSettings from "./CSMSettingsComponents/CSMCalibrationSettings.vue"; import CSMCalibrationSettings from "./CSMSettingsComponents/CSMCalibrationSettings.vue";
import miniStreamDisplay from "../../genericComponents/miniStreamDisplay.vue"; import miniStreamDisplay from "../../genericComponents/miniStreamDisplay.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
// Export main app // Export main app
export default { export default {

View file

@ -1,5 +1,5 @@
<template> <template>
<div id="CSMCalibrationSettings" v-observe-visibility="visibilityChanged"> <div id="CSMCalibrationSettings" ref="CSMCalibrationSettingsContainer" class="uk-width-large">
<!--Show auto calibrate if default plugin is enabled--> <!--Show auto calibrate if default plugin is enabled-->
<div v-if="'calibrate_xy' in actions" class="uk-margin-small"> <div v-if="'calibrate_xy' in actions" class="uk-margin-small">
<action-button <action-button
@ -58,7 +58,7 @@
import ActionButton from "@/components/labThingsComponents/actionButton.vue"; import ActionButton from "@/components/labThingsComponents/actionButton.vue";
import matrixDisplay from "@/components/ui/matrixDisplay.vue"; import matrixDisplay from "@/components/ui/matrixDisplay.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue"; import { useIntersectionObserver } from "@vueuse/core";
// Export main app // Export main app
export default { export default {
@ -95,6 +95,16 @@ export default {
}, },
}, },
mounted() {
useIntersectionObserver(
this.$refs.CSMCalibrationSettingsContainer,
([{ isIntersecting }]) => {
this.visibilityChanged(isIntersecting);
},
{ threshold: 0.0 }
);
},
methods: { methods: {
visibilityChanged(isVisible) { visibilityChanged(isVisible) {
if (isVisible) { if (isVisible) {

View file

@ -26,7 +26,6 @@ import cameraCalibrationSettings from "./cameraSettingsComponents/cameraCalibrat
import miniStreamDisplay from "../../genericComponents/miniStreamDisplay.vue"; import miniStreamDisplay from "../../genericComponents/miniStreamDisplay.vue";
import ServerSpecifiedPropertyControl from "../../labThingsComponents/serverSpecifiedPropertyControl.vue"; import ServerSpecifiedPropertyControl from "../../labThingsComponents/serverSpecifiedPropertyControl.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue";
// Export main app // Export main app
export default { export default {

View file

@ -30,7 +30,7 @@ export default {
name: "CameraCalibrationSettings", name: "CameraCalibrationSettings",
components: { components: {
ServerSpecifiedActionButton, ServerSpecifiedActionButton
}, },
props: { props: {

View file

@ -8,7 +8,6 @@
<script> <script>
import appSettings from "./displaySetttingsComponents/appSettings.vue"; import appSettings from "./displaySetttingsComponents/appSettings.vue";
import streamSettings from "./displaySetttingsComponents/streamSettings.vue"; import streamSettings from "./displaySetttingsComponents/streamSettings.vue";
import { markRaw } from "vue";
// Export main app // Export main app
export default { export default {

View file

@ -1,5 +1,5 @@
<template> <template>
<div id="stageSettings" v-observe-visibility="visibilityChanged" class="uk-width-large"> <div id="stageSettings" ref="stageSettingsContainer" class="uk-width-large">
The microscope stage is a <b>{{ stageType }}</b> The microscope stage is a <b>{{ stageType }}</b>
<div> <div>
<div class="uk-margin"> <div class="uk-margin">
@ -30,7 +30,7 @@
<script> <script>
import ActionButton from "../../labThingsComponents/actionButton.vue"; import ActionButton from "../../labThingsComponents/actionButton.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue"; import { useIntersectionObserver } from "@vueuse/core";
export default { export default {
name: "StageSettings", name: "StageSettings",
@ -51,6 +51,16 @@ export default {
}, },
}, },
mounted() {
useIntersectionObserver(
this.$refs.stageSettingsContainer,
([{ isIntersecting }]) => {
this.visibilityChanged(isIntersecting);
},
{ threshold: 0.0 }
);
},
methods: { methods: {
visibilityChanged(isVisible) { visibilityChanged(isVisible) {
if (isVisible) { if (isVisible) {

View file

@ -1,7 +1,7 @@
<template> <template>
<div uk-grid class="uk-height-1-1 uk-margin-remove uk-padding-remove"> <div uk-grid class="uk-height-1-1 uk-margin-remove uk-padding-remove">
<div class="control-component uk-padding-small"> <div class="control-component uk-padding-small">
<div v-show="!scanning" v-observe-visibility="visibilityChanged" class="uk-padding-small"> <div v-show="!scanning" ref="slideScanContent" class="uk-padding-small">
<h4 v-if="workflowDisplayName" class="workflow-name"> <h4 v-if="workflowDisplayName" class="workflow-name">
{{ workflowDisplayName }} {{ workflowDisplayName }}
</h4> </h4>
@ -117,7 +117,7 @@ import actionProgressBar from "../labThingsComponents/actionProgressBar.vue";
import MiniStreamDisplay from "../genericComponents/miniStreamDisplay.vue"; import MiniStreamDisplay from "../genericComponents/miniStreamDisplay.vue";
import ActionButton from "../labThingsComponents/actionButton.vue"; import ActionButton from "../labThingsComponents/actionButton.vue";
// vue3 migration // vue3 migration
import { markRaw } from "vue"; import { useIntersectionObserver } from "@vueuse/core";
export default { export default {
name: "SlideScanContent", name: "SlideScanContent",
@ -129,6 +129,7 @@ export default {
actionProgressBar, actionProgressBar,
MiniStreamDisplay, MiniStreamDisplay,
ActionButton, ActionButton,
ServerSpecifiedPropertyControl
}, },
data() { data() {
@ -162,6 +163,18 @@ export default {
this.readSettings(); this.readSettings();
}, },
mounted() {
useIntersectionObserver(
this.$refs.slideScanContent,
([{ isIntersecting }]) => {
this.visibilityChanged(isIntersecting);
},
{
threshold: 0.0, // Adjust as needed
},
);
},
methods: { methods: {
visibilityChanged(isVisible) { visibilityChanged(isVisible) {
if (isVisible) { if (isVisible) {

View file

@ -36,42 +36,21 @@
<script> <script>
// vue3 migration // vue3 migration
import { eventBus } from "../../eventBus.js"; import { eventBus } from "../../eventBus.js";
import { ref } from "vue";
import { useIntersectionObserver } from "@vueuse/core"; import { useIntersectionObserver } from "@vueuse/core";
// Export main app // Export main app
export default { export default {
name: "StreamDisplay", name: "StreamDisplay",
setup() {
const streamDisplay = ref(null);
const isVisible = ref(false);
useIntersectionObserver(
streamDisplay,
([{ isIntersecting }]) => {
isVisible.value = isIntersecting;
},
{
threshold: 0.1,
}
);
return {
streamDisplay,
isVisible,
};
},
data: function () { data: function () {
return { return {
isVisible: false,
displaySize: [0, 0], displaySize: [0, 0],
displayPosition: [0, 0], displayPosition: [0, 0],
resizeTimeoutId: setTimeout(this.doneResizing, 500), resizeTimeoutId: setTimeout(this.doneResizing, 500),
}; };
}, },
computed: { computed: {
streamEnabled: function () { streamEnabled: function () {
return this.$store.getters.ready && !this.$store.state.disableStream; return this.$store.getters.ready && !this.$store.state.disableStream;
@ -86,12 +65,23 @@ export default {
}, },
mounted() { mounted() {
//set up an intersection observer
useIntersectionObserver(
this.$refs.streamDisplay,
([{ isIntersecting }]) => {
this.isVisible = isIntersecting;
},
{
threshold: 0.0,
}
);
// A global signal listener to flash the stream element // A global signal listener to flash the stream element
this.onFlashStream = () => { this.onFlashStream = () => {
this.flashStream(); this.flashStream();
}; };
eventBus.on("globalFlashStream", this.onFlashStream); eventBus.on("globalFlashStream", this.onFlashStream);
// Mutation observer // Mutation observer
this.sizeObserver = new ResizeObserver(() => { this.sizeObserver = new ResizeObserver(() => {
this.handleResize(); // For any element attached to the observer, run handleResize() on change this.handleResize(); // For any element attached to the observer, run handleResize() on change
@ -120,9 +110,6 @@ export default {
}, },
methods: { methods: {
visibilityChanged(isVisible) {
this.isVisible = isVisible;
},
flashStream: function () { flashStream: function () {
// Run an animation that flashes the stream (for capture feedback) // Run an animation that flashes the stream (for capture feedback)
let element = this.$refs.streamDisplay; let element = this.$refs.streamDisplay;