ui_migration bugfix(component) streamContent.vue, Bugfix resize warns wrong spelling of doneResizing to correct: handleDoneResize and move resizeTimeoutId to mounted
This commit is contained in:
parent
67560a21f8
commit
702d18552d
1 changed files with 33 additions and 22 deletions
|
|
@ -52,7 +52,7 @@ export default {
|
||||||
isVisible: false,
|
isVisible: false,
|
||||||
displaySize: [0, 0],
|
displaySize: [0, 0],
|
||||||
displayPosition: [0, 0],
|
displayPosition: [0, 0],
|
||||||
resizeTimeoutId: setTimeout(this.doneResizing, 500),
|
resizeTimeoutId: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -71,32 +71,33 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
//set up an intersection observer
|
// Initial Timeout
|
||||||
useIntersectionObserver(
|
this.resizeTimeoutId = setTimeout(this.handleDoneResize, 500);
|
||||||
|
|
||||||
|
// set up an intersection observer
|
||||||
|
// We capture the 'stop' function returned by VueUse so we can kill it later
|
||||||
|
const { stop } = useIntersectionObserver(
|
||||||
this.$refs.streamDisplay,
|
this.$refs.streamDisplay,
|
||||||
([{ isIntersecting }]) => {
|
([{ isIntersecting }]) => {
|
||||||
this.isVisible = isIntersecting;
|
this.isVisible = isIntersecting;
|
||||||
},
|
},
|
||||||
{
|
{ threshold: 0.0 },
|
||||||
threshold: 0.0,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
this.stopIntersectionObserver = stop;
|
||||||
// A global signal listener to flash the stream element
|
// A global signal listener to flash the stream element
|
||||||
this.onFlashStream = () => {
|
eventBus.on("globalFlashStream", this.flashStream);
|
||||||
this.flashStream();
|
|
||||||
};
|
|
||||||
|
|
||||||
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
|
||||||
});
|
});
|
||||||
// Fetch streamDisplay component by ref
|
|
||||||
if (this.$refs.streamDisplay && this.$refs.streamDisplay.parentNode) {
|
// Safely fetch the DOM element (handles both native HTML and Vue components)
|
||||||
const streamDisplayElement = this.$refs.streamDisplay.parentNode;
|
const streamElement = this.$refs.streamDisplay?.$el || this.$refs.streamDisplay;
|
||||||
|
|
||||||
|
if (streamElement && streamElement.parentNode) {
|
||||||
// Attach streamDisplay to the size observer
|
// Attach streamDisplay to the size observer
|
||||||
this.sizeObserver.observe(streamDisplayElement);
|
this.sizeObserver.observe(streamElement.parentNode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -104,13 +105,23 @@ export default {
|
||||||
// Do nothing: preview stream now runs all the time
|
// Do nothing: preview stream now runs all the time
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUnmount: function () {
|
beforeUnmount() {
|
||||||
// Disconnect the size observer
|
// Kill the timeout
|
||||||
this.sizeObserver.disconnect();
|
clearTimeout(this.resizeTimeoutId);
|
||||||
// Remove from the array of active streams
|
|
||||||
this.store.removeStream(this.$.uid);
|
// Kill the Intersection Observer
|
||||||
// close signal
|
if (this.stopIntersectionObserver) {
|
||||||
eventBus.off("globalFlashStream", this.onFlashStream);
|
this.stopIntersectionObserver();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unregister the event bus listener
|
||||||
|
eventBus.off("globalFlashStream", this.flashStream);
|
||||||
|
|
||||||
|
// Disconnect the size Observer
|
||||||
|
if (this.sizeObserver) {
|
||||||
|
this.sizeObserver.disconnect();
|
||||||
|
this.store.removeStream(this.$.uid);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue