File tree Expand file tree Collapse file tree 3 files changed +12
-6
lines changed Expand file tree Collapse file tree 3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 1+ html .ot-with-popup , html .ot-with-popup > body {
2+ overflow : hidden;
3+ position : fixed ; /* To prevent scroll on mobile devices.
4+ One must also set top property manually
5+ to prevent scrolling page to top. */
6+ }
17.ot-popup-background {
28 position : fixed ;
39 right : 0 ;
Original file line number Diff line number Diff line change @@ -38,7 +38,6 @@ let%client popup
3838 ?(onclose = fun () -> Lwt. return_unit)
3939 ?(close_on_background_click= false )
4040 ?(close_on_escape= close_button <> None )
41- ?(ios_scroll_pos_fix= true )
4241 gen_content =
4342 let a = (a :> Html_types.div_attrib attrib list ) in
4443 let gen_content =
@@ -59,18 +58,20 @@ let%client popup
5958 | None -> ()
6059 in
6160
62- if ios_scroll_pos_fix then scroll_pos := Dom_html. document##.body##.scrollTop;
61+ (* Hack to prevent body scrolling behind the popup on mobile devices: *)
62+ scroll_pos := Dom_html. document##.body##.scrollTop;
6363 html_ManipClass_add " ot-with-popup" ;
64- if ios_scroll_pos_fix then Dom_html. document##.body##.scrollTop := ! scroll_pos;
64+ Dom_html. document##.body##.style##.top :=
65+ Js. string (Printf. sprintf " %dpx" (- ! scroll_pos));
6566
6667 let kill_keydown_thread = ref @@ fun () -> () in
6768
6869 let do_close () =
6970 if (Dom_html. document##getElementsByClassName (Js. string " ot-popup" ))
7071 # #.length = 1 then begin
7172 html_ManipClass_remove " ot-with-popup" ;
72- if ios_scroll_pos_fix then
73- Dom_html. document##.body##.scrollTop := ! scroll_pos
73+ Dom_html. document##.body##.style##.top := Js. string " " ;
74+ Dom_html. window# #scroll 0 ! scroll_pos
7475 end ;
7576 let () = Eliom_lib.Option. iter Manip. removeSelf ! popup in
7677 ! kill_keydown_thread () ;
Original file line number Diff line number Diff line change @@ -71,7 +71,6 @@ val popup :
7171 -> ?onclose : (unit -> unit Lwt .t )
7272 -> ?close_on_background_click : bool
7373 -> ?close_on_escape : bool
74- -> ?ios_scroll_pos_fix : bool
7574 -> ((unit -> unit Lwt .t ) -> [< div_content ] elt Lwt .t )
7675 -> [> `Div ] elt Lwt .t
7776
You can’t perform that action at this time.
0 commit comments