How to solve the problem that setTimeout stops running when chrome minimizes the window

use chrome to open normal slide rotation, minimize the window, switch back every once in a while, and flash more than one slide at a time.
how to implement, like swiper, stop the timer when the window is minimized. Open it again and resume the last movement

some people say that onblur/onfocus is used, but when the console is opened, it is also considered to be a blur stop timer. Is there a better way?

Apr.02,2021

listen visibilitychange event
reference link: https://developer.mozilla.org.

Menu