let isRunning = ref false let start base ~onStart ~onEnd = if not !isRunning then let () = isRunning := true in let () = onStart () in let () = Element.setClassName base "g-Animation" in let delay = 400 in let _ = Js.Global.setTimeout (fun () -> let () = Element.setClassName base "" in let () = onEnd () in isRunning := false) delay in () else () let replaceChild scrollBase base mkChild = start base ~onStart:(fun _ -> let () = Element.setScrollTop scrollBase 0 in Element.appendChild base (mkChild ())) ~onEnd:(fun _ -> let _ = Element.removeFirstChild base in ())