blob: 35294dcb728a9638b8767c4f0bc7d22d2714092f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
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
())
|