-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Lib: add wheel event * Lib: rewrite addMousewheelEventListenerWithOptions * Lib: delta_mode enum instead of int * Lib: add onwheel to eventTarget * Tests: add example which uses wheel event * Misc: changes note #1272 * Lib: use mousewheelEvent instead of new wheelEvent * Lib: lwt_js for wheel * Misc: fix indentation
- Loading branch information
Showing
8 changed files
with
123 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(executables | ||
(names test_wheel) | ||
(libraries js_of_ocaml) | ||
(modes js) | ||
(preprocess | ||
(pps js_of_ocaml-ppx))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html style="height: 100%;"> | ||
|
||
<head> | ||
<title>test_wheel</title> | ||
<script defer type="text/javascript" src="test_wheel.bc.js"></script> | ||
</head> | ||
|
||
<body> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
open Js_of_ocaml | ||
|
||
let optdef_to_string o = | ||
match Js.Optdef.to_option o with | ||
| Some v -> Int.to_string v | ||
| None -> "undefined" | ||
|
||
let () = | ||
let html = | ||
Js.Opt.get | ||
(Dom_html.document##querySelector (Js.string "html")) | ||
(fun _ -> assert false) | ||
in | ||
html##.onwheel := | ||
Dom.handler (fun (event : Dom_html.mousewheelEvent Js.t) -> | ||
Firebug.console##debug event; | ||
let deltaX = event##.deltaX in | ||
let deltaY = event##.deltaY in | ||
let deltaZ = event##.deltaZ in | ||
let deltaMode = event##.deltaMode in | ||
let wheelDelta = event##.wheelDelta in | ||
let wheelDeltaX = event##.wheelDeltaX in | ||
let wheelDeltaY = event##.wheelDeltaY in | ||
Printf.printf "deltaX: %f; " deltaX; | ||
Printf.printf "deltaY: %f; " deltaY; | ||
Printf.printf "deltaZ: %f; " deltaZ; | ||
Printf.printf | ||
"deltaMode: %s; " | ||
(match deltaMode with | ||
| Delta_pixel -> "Delta_pixel" | ||
| Delta_line -> "Delta_line" | ||
| Delta_page -> "Delta_page"); | ||
Printf.printf "wheelDelta: %d; " wheelDelta; | ||
Printf.printf "wheelDeltaX: %s; " (optdef_to_string wheelDeltaX); | ||
Printf.printf "wheelDeltaY: %s\n" (optdef_to_string wheelDeltaY); | ||
Js._false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters