🐛 Reduce intersection observer threshold (#4824)
* 🐛 Reduce intersection observer threshold When this value is 1, scrolling down the page (sometimes?) triggers the value to change - probably something changes invisibly. Setting it to anything less than 1 seems to cure the issue, and there are no longer unwanted triggers of changes. 1% also seems to make more sense here than 100% - we want the webcam to load whenever even a tiny amount of it is visible. * ♻️ Change visibility observer threshold to 1% * ♻️ Use log.debug instead of console.debug --------- Co-authored-by: Gina Häußge <gina@octoprint.org>
This commit is contained in:
1 parent
c847ed9d13
commit
d08393d450
1 file changed
+5
-4
@@ -57,19 +57,20 @@ $(function () {
|
||||
self._visibleWebcam = undefined;
|
||||
|
||||
self._dispatchWebcamVisibilityChange = function (target, visible) {
|
||||
log.debug(`Webcam visibility of #${target.id} changed to ${visible}`);
|
||||
var vm = ko.dataFor(target.children[0]);
|
||||
if (vm === self) {
|
||||
console.debug(
|
||||
log.debug(
|
||||
`VM for webcam #${target.id} is not bound, skipping visibility update`
|
||||
);
|
||||
} else if (vm === undefined) {
|
||||
console.debug(
|
||||
log.debug(
|
||||
`VM for webcam #${target.id} not found, skipping visibility update`
|
||||
);
|
||||
} else if (typeof vm.onWebcamVisibilityChange === "function") {
|
||||
vm.onWebcamVisibilityChange(visible);
|
||||
} else {
|
||||
console.debug(
|
||||
log.debug(
|
||||
`VM for webcam #${target.id} does not declare 'onWebcamVisibilityChange(visible)', skipping visibility update (vm=${vm.constructor.name})`
|
||||
);
|
||||
}
|
||||
@@ -122,7 +123,7 @@ $(function () {
|
||||
var options = {
|
||||
root: document.querySelector("#webcam_plugins_container"),
|
||||
rootMargin: "0px",
|
||||
threshold: 1.0
|
||||
threshold: 0.01
|
||||
};
|
||||
var callback = function (entries) {
|
||||
var visible = entries[0].isIntersecting;
|
||||
|
||||
Reference in new issue
Block a user