Skip to content

Commit 963e1ff

Browse files
committed
WIP mobile
1 parent a5ba15c commit 963e1ff

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

Diff for: src/engine/controller.ml

+12-5
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ let keyboard_setup (window : Window.window) =
6767
()
6868

6969
let touch_setup (window : Window.window) =
70-
let target = Brr.Window.as_target Brr.G.window in
70+
let target = Brr.G.document |> Brr.Document.body |> Brr.El.as_target in
7171
let start = ref None in
7272
let coord_of_event ev =
7373
let mouse = Brr.Ev.as_type ev |> Brr.Ev.Pointer.as_mouse in
@@ -83,9 +83,13 @@ let touch_setup (window : Window.window) =
8383
else ()
8484
in
8585
let touchstart (ev : Brr.Ev.Pointer.t Brr.Ev.t) =
86+
Brr.Ev.prevent_default ev;
87+
Brr.Ev.stop_immediate_propagation ev;
88+
Brr.Ev.stop_propagation ev;
8689
check_condition ev @@ fun () -> start := Some (coord_of_event ev)
8790
in
88-
let _listener = Brr.Ev.listen Brr.Ev.pointerdown touchstart target in
91+
let opts = Brr.Ev.listen_opts ~passive:false () in
92+
let _listener = Brr.Ev.listen ~opts Brr.Ev.pointerdown touchstart target in
8993
let take_decision start (end_x, end_y) =
9094
match start with
9195
| None -> `None
@@ -98,10 +102,13 @@ let touch_setup (window : Window.window) =
98102
if abs_x > abs_y then (mov_x, abs_x, win_x) else (mov_y, abs_y, win_y)
99103
in
100104
if abs /. win < 0.1 then `None
101-
else if mov <= 0. then `Backward
102-
else `Forward
105+
else if mov <= 0. then `Forward
106+
else `Backward
103107
in
104108
let touchend (ev : Brr.Ev.Pointer.t Brr.Ev.t) =
109+
Brr.Ev.prevent_default ev;
110+
Brr.Ev.stop_immediate_propagation ev;
111+
Brr.Ev.stop_propagation ev;
105112
check_condition ev @@ fun () ->
106113
let end_ = coord_of_event ev in
107114
let () =
@@ -116,7 +123,7 @@ let touch_setup (window : Window.window) =
116123
in
117124
start := None
118125
in
119-
let _listener = Brr.Ev.listen Brr.Ev.pointerup touchend target in
126+
let _listener = Brr.Ev.listen ~opts Brr.Ev.pointerup touchend target in
120127

121128
()
122129

Diff for: src/engine/slipshow.css

+5
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,8 @@ h1:not(#slip-toc h1) {
205205
.slip-current-step .slip-step {
206206
background-color: red;
207207
}
208+
209+
body {
210+
touch-action: pinch-zoom;
211+
}
212+

0 commit comments

Comments
 (0)