@@ -296,10 +296,10 @@ let _debug_msg _s = ()
296296 *)
297297
298298let handle_drag element move stop click =
299- let fuzz = 4 in
299+ let fuzz = 4. in
300300 element##.onmousedown :=
301301 Html. handler (fun ev ->
302- let x0 = ev##.clientX and y0 = ev##.clientY in
302+ let x0 = Js. to_float ev##.clientX and y0 = Js. to_float ev##.clientY in
303303 (*
304304debug_msg (Format.sprintf "Mouse down %d %d" x0 y0);
305305*)
@@ -309,11 +309,12 @@ debug_msg (Format.sprintf "Mouse down %d %d" x0 y0);
309309 Html. document
310310 Html.Event. mousemove
311311 (Html. handler (fun ev ->
312- let x = ev##.clientX and y = ev##.clientY in
312+ let x = Js. to_float ev##.clientX and y = Js. to_float ev##.clientY in
313313 (*
314314debug_msg (Format.sprintf "Mouse move %d %d %d %d" x0 y0 x y);
315315*)
316- if (not ! started) && (abs (x - x0) > fuzz || abs (y - y0) > fuzz)
316+ if (not ! started)
317+ && (abs_float (x -. x0) > fuzz || abs_float (y -. y0) > fuzz)
317318 then (
318319 started := true ;
319320 element##.style##.cursor := Js. string " move" );
@@ -337,14 +338,14 @@ debug_msg (Format.sprintf "Mouse up %d %d %d %d" x0 y0 ev##clientX ev##clientY);
337338 if ! started
338339 then (
339340 element##.style##.cursor := Js. string " " ;
340- stop ev##.clientX ev##.clientY)
341- else click ev##.clientX ev##.clientY;
341+ stop ( Js. to_float ev##.clientX) ( Js. to_float ev##.clientY) )
342+ else click ( Js. to_float ev##.clientX) ( Js. to_float ev##.clientY) ;
342343 Js. _true))
343344 Js. _true);
344345 Js. _true)
345346
346347let handle_touch_events element move stop cancel click =
347- let fuzz = 4 in
348+ let fuzz = 4. in
348349 ignore
349350 (Html. addEventListener
350351 element
@@ -354,7 +355,8 @@ let handle_touch_events element move stop cancel click =
354355 (ev##.changedTouches##item 0 )
355356 (fun touch ->
356357 let id = touch##.identifier in
357- let x0 = touch##.clientX and y0 = touch##.clientY in
358+ let x0 = Js. to_float touch##.clientX
359+ and y0 = Js. to_float touch##.clientY in
358360 (*
359361debug_msg (Format.sprintf "Touch start %d %d" x0 y0);
360362*)
@@ -370,12 +372,14 @@ debug_msg (Format.sprintf "Touch start %d %d" x0 y0);
370372 (fun touch ->
371373 if touch##.identifier = id
372374 then (
373- let x = touch##.clientX and y = touch##.clientY in
375+ let x = Js. to_float touch##.clientX
376+ and y = Js. to_float touch##.clientY in
374377 (*
375378 debug_msg (Format.sprintf "Touch move %d %d %d %d" x0 y0 x y);
376379*)
377380 if (not ! started)
378- && (abs (x - x0) > fuzz || abs (y - y0) > fuzz)
381+ && (abs_float (x -. x0) > fuzz
382+ || abs_float (y -. y0) > fuzz)
379383 then (
380384 started := true ;
381385 element##.style##.cursor := Js. string " move" );
@@ -399,7 +403,8 @@ debug_msg (Format.sprintf "Touch start %d %d" x0 y0);
399403 (fun touch ->
400404 if touch##.identifier = id
401405 then (
402- let x = touch##.clientX and y = touch##.clientY in
406+ let x = Js. to_float touch##.clientX
407+ and y = Js. to_float touch##.clientY in
403408 (*
404409debug_msg (Format.sprintf "Touch end %d %d %d %d" x0 y0 x y);
405410*)
@@ -577,7 +582,7 @@ let to_screen z = ((z.x +. 1.) *. r, (z.y +. 1.) *. r)
577582*)
578583let from_screen canvas x y =
579584 let rx, ry, dx, dy = screen_transform canvas in
580- let z = { x = (float x -. dx) /. rx; y = (float y -. dy) /. ry } in
585+ let z = { x = (x -. dx) /. rx; y = (y -. dy) /. ry } in
581586 let n = norm z in
582587 if n < = 1. -. eps then z else sdiv z (n /. (1. -. eps))
583588
@@ -1620,10 +1625,8 @@ debug_msg (Format.sprintf "Resize %d %d" w h);
16201625 let p = ref (- 1 ) in
16211626 for i = 0 to Array. length boxes.bw - 1 do
16221627 if Array. unsafe_get boxes.bw i > 0.
1623- && abs_float (float x -. Array. unsafe_get boxes.bx i)
1624- < Array. unsafe_get boxes.bw i
1625- && abs_float (float y -. Array. unsafe_get boxes.by i)
1626- < Array. unsafe_get boxes.bh i
1628+ && abs_float (x -. Array. unsafe_get boxes.bx i) < Array. unsafe_get boxes.bw i
1629+ && abs_float (y -. Array. unsafe_get boxes.by i) < Array. unsafe_get boxes.bh i
16271630 then p := i
16281631 done ;
16291632 ! p
@@ -1644,7 +1647,7 @@ debug_msg (Format.sprintf "Resize %d %d" w h);
16441647 in
16451648 canvas##.onmousemove :=
16461649 Html. handler (fun ev ->
1647- update_cursor ev##.clientX ev##.clientY;
1650+ update_cursor ( Js. to_float ev##.clientX) ( Js. to_float ev##.clientY) ;
16481651 Js. _false);
16491652 handle_drag
16501653 canvas
0 commit comments