2.8 解决监控屏幕适配问题

This commit is contained in:
jl-zhoujl2
2023-02-08 13:51:54 +08:00
parent 585471d9a1
commit 691c72286a

View File

@ -141,6 +141,7 @@ const ScreenVideoPlay: React.FC<ScreenVideoPlayProps> = (props) => {
function setWndCover() {
var iWidth = window.innerWidth;
var iHeight = window.innerHeight;
let scale = window.innerHeight / 1080;
var oDivRect = playWnd.current.getBoundingClientRect();
var iCoverLeft = (oDivRect.left < 0) ? Math.abs(oDivRect.left) : 0;
@ -222,15 +223,16 @@ const ScreenVideoPlay: React.FC<ScreenVideoPlayProps> = (props) => {
// 监听滚动条scroll事件使插件窗口跟随浏览器滚动而移动
const resize = () => {
if (oWebControl != null) {
let scale = window.innerHeight / 1080;
oWebControl.JS_Resize(playWnd.current.clientWidth * scale, playWnd.current.clientHeight * scale);
setWndCover();
}
};
window.addEventListener("resize", debounce(() => resize(), 100));
window.addEventListener("scroll", debounce(() => resize(), 100));
window.addEventListener("resize", debounce(() => resize(), 1000));
window.addEventListener("scroll", debounce(() => resize(), 1000));
return () => {
window.removeEventListener("resize", debounce(() => resize(), 100));
window.removeEventListener("scroll", debounce(() => resize(), 100));
window.removeEventListener("resize", debounce(() => resize(), 1000));
window.removeEventListener("scroll", debounce(() => resize(), 1000));
if (oWebControl != null) {
oWebControl.JS_HideWnd(); // 先让窗口隐藏,规避可能的插件窗口滞后于浏览器消失问题
oWebControl.JS_Disconnect().then(function () { // 断开与插件服务连接成功