@@ -82,7 +82,6 @@ let%shared drawer
8282 ?(position = `Left )
8383 ?(opened = false )
8484 ?(swipe = true )
85- ?(ios_scroll_pos_fix= true )
8685 ?(onclose : (unit -> unit ) Eliom_client_value. t option )
8786 ?(onopen : (unit -> unit ) Eliom_client_value. t option )
8887 ?(wrap_close = fun f -> f)
@@ -114,8 +113,8 @@ let%shared drawer
114113 let close = [% client
115114 ((fun () ->
116115 remove_class ~% bckgrnd " open" ;
117- if ~% ios_scroll_pos_fix then
118- Dom_html. document##.body##.scrollTop := ! scroll_pos;
116+ Dom_html. document##.body##.style##.top := Js. string " " ;
117+ Dom_html. window# #scroll 0 ! scroll_pos;
119118 add_class ~% bckgrnd " closing" ;
120119 Lwt. cancel ! (~% touch_thread);
121120 Lwt_js_events. async (fun () ->
@@ -129,12 +128,11 @@ let%shared drawer
129128
130129 let open_ = [% client
131130 ((fun () ->
132- if ~% ios_scroll_pos_fix then
133- scroll_pos := Dom_html. document##.body##.scrollTop;
131+ scroll_pos := (Js.Unsafe. coerce Dom_html. window)##.pageYOffset;
134132 add_class ~% bckgrnd " open" ;
135133 Eliom_lib.Option. iter (fun f -> f () ) ~% onopen;
136- if ~% ios_scroll_pos_fix then
137- Dom_html. document##.body##.scrollTop := ! scroll_pos;
134+ Dom_html. document##.body##.style##.top :=
135+ Js. string ( Printf. sprintf " %dpx " ( - ! scroll_pos)) ;
138136 add_class ~% bckgrnd " opening" ;
139137 Lwt. cancel ! (~% touch_thread);
140138 Lwt. async (fun () ->
0 commit comments