Skip to content

Commit f9e0a7e

Browse files
committed
improve that wierd bug fix
1 parent a750ab9 commit f9e0a7e

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

bun.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ export default function litecanvas(settings = {}) {
12101210
*/
12111211
resume() {
12121212
if (_initialized && !_rafid) {
1213-
_accumulated = 0
1213+
_accumulated = _deltaTime
12141214
_lastFrameTime = performance.now()
12151215
_rafid = raf(drawFrame)
12161216
}
@@ -1506,13 +1506,14 @@ export default function litecanvas(settings = {}) {
15061506
)
15071507
}
15081508

1509-
// this seems to solve a strange bug that drop the FPS
1509+
// this seems to solve a wierd bug that drop the FPS
15101510
// when switching tabs in the browser
1511-
on(root, 'focus', () => {
1512-
DEV: console.warn('[litecanvas] engine loop restarted on "focus" event')
1513-
instance.pause()
1514-
instance.resume()
1515-
})
1511+
setInterval(() => {
1512+
if (_rafid) {
1513+
instance.pause()
1514+
instance.resume()
1515+
}
1516+
}, 5000)
15161517

15171518
// start the engine
15181519
_initialized = true

0 commit comments

Comments
 (0)