Skip to content

Commit fa5972d

Browse files
balatvasilisp
authored andcommitted
Carousel: make it possible to customize the spinner for lazy carousels (#166)
1 parent c233659 commit fa5972d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/widgets/ot_carousel.eliom

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ let%shared default_fail e =
526526

527527
(* on the client side we generate the contents of the initially visible page
528528
asynchronously so the tabs will be rendered right away *)
529-
let%client generate_initial_contents sleeper gen =
529+
let%client generate_initial_contents ~spinner sleeper gen =
530530
let s = spinner () in
531531
begin Lwt.async @@ fun () ->
532532
let%lwt contents = generate_content gen in
@@ -539,7 +539,7 @@ let%client generate_initial_contents sleeper gen =
539539
Lwt.return (s, ref @@ None)
540540

541541
(* on the server side we generate all the visible contents right away *)
542-
let%server generate_initial_contents _ gen =
542+
let%server generate_initial_contents ~spinner:_ _ gen =
543543
let%lwt contents = generate_content gen in
544544
Lwt.return (contents, ref @@ None)
545545

@@ -556,14 +556,15 @@ let%shared make_lazy
556556
?full_height
557557
?make_transform
558558
?make_page_attribute
559+
?(spinner = spinner)
559560
gen_contents =
560561
let gen_contents = (gen_contents :>
561562
(unit -> Html_types.div_content elt Lwt.t) Eliom_shared.Value.t list) in
562563

563564
let sleeper, wakener = Lwt.wait () in
564565
let mk_contents : int -> 'gen -> ('a elt * ('a elt * 'gen) option ref) Lwt.t
565566
= fun i gen -> if i = position
566-
then generate_initial_contents sleeper gen
567+
then generate_initial_contents ~spinner sleeper gen
567568
else Lwt.return @@ let s = spinner () in s, ref @@ Some (s, gen)
568569
in
569570
let%lwt contents, spinners_and_generators =

src/widgets/ot_carousel.eliomi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ val make :
130130
switching to a page for the first time. The initial page (defined by
131131
[position] is directly generated on the server side (if [make_lazy] is
132132
invoked on the server).
133+
Parameter [?spinner] make it possible to customize the element
134+
that is displayed while page is loading.
133135
*)
134136
val make_lazy :
135137
?a: [< Html_types.div_attrib ] Eliom_content.Html.attrib list ->
@@ -149,6 +151,7 @@ val make_lazy :
149151
int ->
150152
Html_types.div_attrib Eliom_content.Html.D.attrib list)
151153
Eliom_shared.Value.t ->
154+
?spinner: (unit -> Html_types.div_content Eliom_content.Html.elt) ->
152155
(unit -> [< Html_types.div_content ] Eliom_content.Html.elt Lwt.t)
153156
Eliom_shared.Value.t list ->
154157
[> `Div ] t Lwt.t

0 commit comments

Comments
 (0)