on master help sign in
Get the touch library working, and bump the version number to 0.7.1.
commitc0deb91a574d0a37a2cebe23d949320edc8d18f2 authorevancz <info@elm-lang.org> dateMon 7 Jan 2013, 00:47 (14 years ago) parentc7928f2
3 files changed+25−22
core-js/Signal/Touch.js+21−18 core-js/cat.bat+2−2 elm/Elm.cabal+2−2
core-js/Signal/Touch.js+21−18
@@ -2,23 +2,26 @@
22Elm.Touch = function() {
33 var touches = Elm.Signal.constant(["Nil"]);
44
5− Value.addListener(document, "touchstart", function(e) {
6− var ts = e.changedTouches;
7− var vs = touches.value;
8− for (var i = ts.length; i--; ) {
9− var t = ts[i];
10− vs = ["Cons", Value.tuple(t.pageX, t.pageY), vs];
11− }
12− Dispatcher.notify(touches.id, vs);
13− });
14− Value.addListener(document, "touchend", function(e) {
15− });
16− Value.addListener(document, "touchcancel", function(e) {
17− });
18− Value.addListener(document, "touchleave", function(e) {
19− });
20− Value.addListener(document, "touchmove", function(e) {
21− });
5+ function touch(t) {
6+ return {_ : [true], x: [t.pageX], y: [t.pageY], id: [t.identifier] };
7+ }
228
23− return {};
9+ function listen(name) {
10+ function update(e) {
11+ var ts = Elm.JavaScript.castJSArrayToList(e.touches);
12+ var hasListener = Dispatcher.notify(touches.id, Elm.List.map(touch)(ts));
13+ if (!hasListener)
14+ return this.removeEventListener(name,arguments.callee,false);
15+ e.preventDefault();
16+ }
17+ Value.addListener(document, name, update);
18+ }
19+
20+ listen("touchstart");
21+ listen("touchmove");
22+ listen("touchend");
23+ listen("touchcancel");
24+ listen("touchleave");
25+
26+ return { touches: touches };
2427}();
core-js/cat.bat+2−2
@@ -1,5 +1,5 @@
1−copy /B Guid.js+foreign\JavaScript.js+foreign\JSON.js+Value.js+List.js+Maybe.js+Char.js+Graphics\Color.js+Graphics\Collage.js+Graphics\Element.js+Text.js+Graphics\Render.js+runtime\Signal.js+runtime\Dispatcher.js+Signal\HTTP.js+Signal\Input.js+Signal\Keyboard.js+Signal\Mouse.js+Signal\Random.js+Signal\Time.js+Signal\Window.js+Date.js+Prelude.js+Dict.js+Set.js+Automaton.js ..\elm-mini.js
1+copy /B Guid.js+foreign\JavaScript.js+foreign\JSON.js+Value.js+List.js+Maybe.js+Char.js+Graphics\Color.js+Graphics\Collage.js+Graphics\Element.js+Text.js+Graphics\Render.js+runtime\Signal.js+runtime\Dispatcher.js+Signal\HTTP.js+Signal\Input.js+Signal\Keyboard.js+Signal\Mouse.js+Signal\Touch.js+Signal\Random.js+Signal\Time.js+Signal\Window.js+Date.js+Prelude.js+Dict.js+Set.js+Automaton.js ..\elm-mini.js
22
33cd ..\elm
44
5−copy /B ..\elm-mini.js elm-runtime-0.7.0.1.js
5+copy /B ..\elm-mini.js elm-runtime-0.7.1.js
elm/Elm.cabal+2−2
@@ -1,6 +1,6 @@
11
22Name: Elm
3−Version: 0.7.0.1
3+Version: 0.7.1
44Synopsis: The Elm language module.
55Description: Elm aims to make client-side web-development more pleasant.
66 It is a statically/strongly typed, functional reactive
@@ -22,7 +22,7 @@ Category: Compiler, Language
2222Build-type: Simple
2323
2424Extra-source-files: changelog.txt
25−Data-files: elm-runtime-0.7.0.1.js
25+Data-files: elm-runtime-0.7.1.js
2626Cabal-version: >=1.8
2727
2828source-repository head