electron 当父浏览器窗口移动时,如何保持子浏览器窗口的相对位置?

m3eecexj  于 2023-08-01  发布在  Electron
关注(0)|答案(1)|浏览(239)

我正在尝试“修复”Linux和Windows中存在的已知问题:https://www.electronjs.org/docs/latest/api/browser-window#platform-notices。
这段代码:

SearchWindow.on("move", function (event) {
    let position = SearchWindow.getPosition()
    console.log("SearchWindow is moved to position ", position[0] + " , " + position [1])
    if (event) {
        child_window.setPosition(position[0], position[1]) // https://www.electronjs.org/docs/latest/api/browser-window#winsetpositionx-y-animate
    }
})

字符串
捕获部分BrowserWindow移动,但不是全部。有办法永久性修复吗?

guicsvcw

guicsvcw1#

与:

clearTimeout()

let t: string | number | NodeJS.Timeout
    if (t) {
        clearInterval(t)
    }

    t = setInterval(() => {
        SearchWindow.on("move", function (event) {
            let position = SearchWindow.getPosition()
            //console.log("SearchWindow is moved to position ", position[0] + " , " + position [1])
            if (event) {
                child_window.setPosition(position[0], position[1]) // https://www.electronjs.org/docs/latest/api/browser-window#winsetpositionx-y-animate
            }
        })
    }, 10)

字符串
我增加了位置重置的频率,现在看来时滞缩短了。不是完美的解决方案,而是一种改进

相关问题