Skip to content

Commit b8766b0

Browse files
committed
feat: 增加可见性监控逻辑
1 parent 8450879 commit b8766b0

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

  • src/components/BootstrapBlazor.HikVision/wwwroot

src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ export async function init(id) {
2222
vision.iWndIndex = result.iWndIndex;
2323
vision.inited = true;
2424

25+
const observer = new IntersectionObserver(() => {
26+
console.log('IntersectionObserver callback');
27+
if (checkVisibility(el)) {
28+
WebVideoCtrl.I_Resize(el.offsetWidth, el.offsetHeight);
29+
}
30+
});
31+
observer.observe(el);
32+
vision.observer = observer;
33+
2534
return true;
2635
}
2736

@@ -309,7 +318,10 @@ export function dispose(id) {
309318
const vision = Data.get(id);
310319
Data.remove(id);
311320

312-
const { realPlaying, logined } = vision;
321+
const { realPlaying, logined, observer } = vision;
322+
if (observer) {
323+
observer.disconnect();
324+
}
313325
if (realPlaying === true) {
314326
stopRealPlay(id);
315327
}

0 commit comments

Comments
 (0)