fn register_on_visibility_change(
    deque: Rc<RefCell<Option<VecDeque<f64>>>>,
) -> Closure<dyn Fn(JsValue)> {
    let fun = move |_| {
        *deque.borrow_mut() = None;
    };

    let closure = fun.into_closure();
    let document = window().unwrap().document().unwrap();
    document
        .add_event_listener_with_callback(
            "visibilitychange",
            closure.as_ref().unchecked_ref(),
        )
        .unwrap();

    closure
}
/// We need to clear the throttle queue when the browser tab is hidden, else
/// the next frame timing will be the time the tab was hidden + render time.
We need to clear the throttle queue when the browser tab is hidden, else
the next frame timing will be the time the tab was hidden + render time.
We need to clear the throttle queue when the browser tab is hidden else the next frame timing will be the time the tab was hidden + render time .
fn register_on_visibility_change(
    deque: Rc<RefCell<Option<VecDeque<f64>>>>,
) -> Closure<dyn Fn(JsValue)> {
    let fun = move |_| {
        *deque.borrow_mut() = None;
    };
    let closure = fun.into_closure();
    let document = window().unwrap().document().unwrap();
    document
        .add_event_listener_with_callback(
            "visibilitychange",
            closure.as_ref().unchecked_ref(),
        )
        .unwrap();
    closure
}
fn register_on_visibility_change ( deque : Rc < RefCell < Option < VecDeque < f64 > > > > , ) -> Closure < dyn Fn ( JsValue ) > { let fun = move | _ | { * deque . borrow_mut ( ) = None ; } ; let closure = fun . into_closure ( ) ; let document = window ( ) . unwrap ( ) . document ( ) . unwrap ( ) ; document . add_event_listener_with_callback ( " " , closure . as_ref ( ) . unchecked_ref ( ) , ) . unwrap ( ) ; closure }
We need to clear the throttle queue when the browser tab is hidden, else
the next frame timing will be the time the tab was hidden + render time.
We need to clear the throttle queue when the browser tab is hidden else the next frame timing will be the time the tab was hidden + render time .
deque
Rc<RefCell<Option<VecDeque<f64>>>>
deque
Rc<RefCell<Option<VecDeque<f64>>>>