Skip to content

Commit 28ab5f0

Browse files
author
Jan Rochel
committed
Ot_page_transition: acceleration using will-change
1 parent 8853cf4 commit 28ab5f0

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

css/ot_page_transition.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
background-color: white;
1010
}
1111

12+
.ot-page-transition-will-change {
13+
will-change: transform;
14+
}
15+
1216
.ot-page-transition-container{
1317
width: 100%;
1418
height: 100%;

src/widgets/ot_page_transition.eliom

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ let set_transition_duration elt t =
2626
Js.Unsafe.coerce ((To_dom.of_element elt)##.style) in
2727
container_style##.transitionDuration := s
2828

29+
let cl_will_change = "ot-page-transition-will-change"
30+
2931
module Make (Conf:PAGE_TRANSITION_CONF) = struct
3032
type screenshot = Conf.screenshot
3133
let screenshot_list = Hashtbl.create 10
@@ -67,6 +69,7 @@ module Make (Conf:PAGE_TRANSITION_CONF) = struct
6769
Lwt.async @@ fun () ->
6870
let h = React.S.value Ot_size.height in
6971
let new_body = Of_dom.of_body Dom_html.document##.body in
72+
Manip.Class.add new_body cl_will_change;
7073
let style = Js.Unsafe.coerce Dom_html.document##.body##.style in
7174
let initial_height = style##.height in
7275
let initial_transition_duration = style##.transitionDuration in
@@ -86,6 +89,7 @@ module Make (Conf:PAGE_TRANSITION_CONF) = struct
8689
let%lwt () = Lwt_js.sleep transition_duration in
8790
Manip.removeSelf screenshot_wrapper;
8891
Manip.SetCss.height new_body (Js.to_string initial_height);
92+
Manip.Class.remove new_body cl_will_change;
8993
style##.transitionDuration := initial_transition_duration;
9094
Lwt.return_unit
9195

@@ -108,6 +112,7 @@ module Make (Conf:PAGE_TRANSITION_CONF) = struct
108112
history_screenshot_container "ot-page-transition-transform-2";
109113
let temporary_body =
110114
D.body [current_screenshot_container; history_screenshot_wrapper] in
115+
Manip.Class.add temporary_body cl_will_change;
111116
Manip.replaceSelf
112117
(Of_dom.of_body Dom_html.document##.body) temporary_body;
113118
let%lwt () = Lwt_js_events.request_animation_frame () in
@@ -116,6 +121,7 @@ module Make (Conf:PAGE_TRANSITION_CONF) = struct
116121
Manip.Class.add temporary_body "ot-page-transition-transform-1";
117122
Manip.Class.remove
118123
history_screenshot_container "ot-page-transition-transform-2";
124+
Manip.Class.remove temporary_body cl_will_change;
119125
Lwt.return_unit
120126

121127
let backward_animation ?(transition_duration=0.5) take_screenshot id =

0 commit comments

Comments
 (0)