Skip to content

Commit 8853cf4

Browse files
author
Jan Rochel
committed
Ot_page_transition: cosmetics
1 parent 48f44aa commit 8853cf4

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

css/ot_page_transition.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
height: 100%;
1515
background-size: contain;
1616
background-repeat: no-repeat;
17+
will-change: transform;
1718
}
1819

1920
.ot-page-transition-transform-1{

src/widgets/ot_page_transition.eliom

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,9 @@ module Make (Conf:PAGE_TRANSITION_CONF) = struct
6363
wrapper,container
6464

6565
let forward_animation_ transition_duration id =
66-
Eliom_client.onload ( fun () ->
67-
Lwt.async (fun () ->
68-
let h =
69-
Js.Optdef.get
70-
Dom_html.window##.innerHeight
71-
(fun () -> assert false) in
66+
Eliom_client.onload @@ fun () ->
67+
Lwt.async @@ fun () ->
68+
let h = React.S.value Ot_size.height in
7269
let new_body = Of_dom.of_body Dom_html.document##.body in
7370
let style = Js.Unsafe.coerce Dom_html.document##.body##.style in
7471
let initial_height = style##.height in
@@ -91,7 +88,6 @@ module Make (Conf:PAGE_TRANSITION_CONF) = struct
9188
Manip.SetCss.height new_body (Js.to_string initial_height);
9289
style##.transitionDuration := initial_transition_duration;
9390
Lwt.return_unit
94-
))
9591

9692
let forward_animation ?(transition_duration=0.5) take_screenshot id =
9793
try
@@ -104,18 +100,14 @@ module Make (Conf:PAGE_TRANSITION_CONF) = struct
104100
transition_duration history_screenshot current_screenshot =
105101
let current_screenshot_container =
106102
Conf.screenshot_container current_screenshot in
107-
let h =
108-
Js.Optdef.get
109-
Dom_html.window##.innerHeight
110-
(fun () -> assert false) in
103+
let h = React.S.value Ot_size.height in
111104
Manip.SetCss.heightPx current_screenshot_container h;
112105
let history_screenshot_wrapper,history_screenshot_container =
113106
wrap_screenshot history_screenshot transition_duration in
114107
Manip.Class.add
115108
history_screenshot_container "ot-page-transition-transform-2";
116109
let temporary_body =
117-
body [current_screenshot_container;
118-
history_screenshot_wrapper] in
110+
D.body [current_screenshot_container; history_screenshot_wrapper] in
119111
Manip.replaceSelf
120112
(Of_dom.of_body Dom_html.document##.body) temporary_body;
121113
let%lwt () = Lwt_js_events.request_animation_frame () in
@@ -129,14 +121,11 @@ module Make (Conf:PAGE_TRANSITION_CONF) = struct
129121
let backward_animation ?(transition_duration=0.5) take_screenshot id =
130122
try
131123
let scr_width,scr_height = Ot_size.get_screen_size () in
132-
let history_screenshot,w,h = pop_screenshot id in
124+
let hist_screenshot,w,h = pop_screenshot id in
133125
if w = scr_width && h = scr_height
134126
then begin
135-
let f current_screenshot =
136-
Lwt.async
137-
(fun () ->
138-
backward_animation_
139-
transition_duration history_screenshot current_screenshot)
127+
let f cur_screenshot = Lwt.async @@ fun () ->
128+
backward_animation_ transition_duration hist_screenshot cur_screenshot
140129
in
141130
take_screenshot f;
142131
Lwt_js.sleep transition_duration

0 commit comments

Comments
 (0)