2Elm.Native.Touch.make = function(elm) {
4 elm.Native = elm.Native || {};
5 elm.Native.Touch = elm.Native.Touch || {};
6 if (elm.Native.Touch.values) return elm.Native.Touch.values;
8 var Signal = Elm.Signal.make(elm);
9 var JS = Elm.JavaScript.make(elm);
10 var Utils = Elm.Native.Utils.make(elm);
16 this.insert = function(key,value) {
18 this.values.push(value);
20 this.lookup = function(key) {
21 var i = this.keys.indexOf(key)
22 return i >= 0 ? this.values[i] : {x:0,y:0,t:0};
24 this.remove = function(key) {
25 var i = this.keys.indexOf(key);
27 var t = this.values[i];
28 this.keys.splice(i,1);
29 this.values.splice(i,1);
32 this.clear = function() {
38 var root = Signal.constant([]),
45 var r = dict.lookup(t.identifier);
46 var point = Utils.getXY(t);
57 var node = elm.display === ElmRuntime.Display.FULLSCREEN ? document : elm.node;
60 var point = Utils.getXY(e);
61 dict.insert(e.identifier,
67 var t = dict.remove(e.identifier);
68 if (Date.now() - t.t < tapTime) {
70 tap = {_:{}, x:t.x, y:t.y};
74 function listen(name, f) {
76 for (var i = e.changedTouches.length; i--; ) { f(e.changedTouches[i]); }
77 var ts = new Array(e.touches.length);
78 for (var i = e.touches.length; i--; ) { ts[i] = touch(e.touches[i]); }
79 elm.notify(root.id, ts);
82 elm.addListener([root.id], node, name, update);
85 listen("touchstart", start);
86 listen("touchmove", function(_){});
87 listen("touchend", end);
88 listen("touchcancel", end);
89 listen("touchleave", end);
93 var point = Utils.getXY(e);
94 for (var i = root.value.length; i--; ) {
95 if (root.value[i].id === mouseID) {
96 root.value[i].x = point._0;
97 root.value[i].y = point._1;
98 elm.notify(root.id, root.value);
103 elm.addListener([root.id], node, "mousedown", function down(e) {
104 node.addEventListener("mousemove", move);
105 e.identifier = mouseID;
107 root.value.push(touch(e));
108 elm.notify(root.id, root.value);
110 elm.addListener([root.id], node, "mouseup", function up(e) {
111 node.removeEventListener("mousemove", move);
112 e.identifier = mouseID;
114 for (var i = root.value.length; i--; ) {
115 if (root.value[i].id === mouseID) {
116 root.value.splice(i, 1);
121 elm.notify(root.id, root.value);
123 elm.addListener([root.id], node, "blur", function blur(e) {
124 node.removeEventListener("mousemove", move);
125 if (root.value.length > 0) {
126 elm.notify(root.id, []);
132 function dependency(f) {
133 var sig = A2( Signal.lift, f, root );
134 root.defaultNumberOfKids += 1;
135 sig.defaultNumberOfKids = 0;
139 var touches = dependency(JS.toList);
141 var taps = function() {
142 var sig = dependency(function(_) { return tap; });
143 sig.defaultNumberOfKids = 1;
144 function pred(_) { var b = hasTap; hasTap = false; return b; }
145 var sig2 = A3( Signal.keepIf, pred, {_:{},x:0,y:0}, sig);
146 sig2.defaultNumberOfKids = 0;
150 return elm.Native.Touch.values = { touches: touches, taps: taps };
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list