|
59 | 59 | }) |
60 | 60 | } |
61 | 61 |
|
62 | | - // dummy log method |
63 | | - const log = () => {}; |
64 | | - |
65 | 62 | // Global vars to cache event state |
66 | 63 | const evCache = []; |
67 | 64 | let prevDiff = -1; |
|
80 | 77 | // The pointerdown event signals the start of a touch interaction. |
81 | 78 | // This event is cached to support 2-finger gestures |
82 | 79 | evCache.push(ev); |
83 | | - log("pointerDown", ev); |
84 | 80 | } |
85 | 81 |
|
86 | 82 | function pointermoveHandler(ev) { |
87 | 83 | // This function implements a 2-pointer horizontal pinch/zoom gesture. |
88 | | - // |
89 | | - // If the distance between the two pointers has increased (zoom in), |
90 | | - // the target element's background is changed to "pink" and if the |
91 | | - // distance is decreasing (zoom out), the color is changed to "lightblue". |
92 | | - // |
93 | | - // This function sets the target element's border to "dashed" to visually |
94 | | - // indicate the pointer's target received a move event. |
95 | | - log("pointerMove", ev); |
96 | | - // ev.target.style.border = "dashed"; |
97 | 84 |
|
98 | 85 | // Find this event in the cache and update its record with this event |
99 | 86 | const index = evCache.findIndex( |
|
108 | 95 |
|
109 | 96 | if (prevDiff > 0) { |
110 | 97 | sendEvent('zoom', { zoom: curDiff - prevDiff}) |
111 | | - if (curDiff > prevDiff) { |
112 | | - // The distance between the two pointers has increased |
113 | | - log("Pinch moving OUT -> Zoom in", ev); |
114 | | - ev.target.style.background = "pink"; |
115 | | - } |
116 | | - if (curDiff < prevDiff) { |
117 | | - // The distance between the two pointers has decreased |
118 | | - log("Pinch moving IN -> Zoom out", ev); |
119 | | - ev.target.style.background = "lightblue"; |
120 | | - } |
121 | 98 | } |
122 | 99 |
|
123 | 100 | // Cache the distance for the next move event |
|
136 | 113 | } |
137 | 114 |
|
138 | 115 | function pointerupHandler(ev) { |
139 | | - log(ev.type, ev); |
140 | | - // Remove this pointer from the cache and reset the target's |
141 | | - // background and border |
| 116 | + // Remove this pointer from the cache |
142 | 117 | removeEvent(ev); |
143 | | - ev.target.style.background = "white"; |
144 | | - // ev.target.style.border = "1px solid black"; |
145 | 118 |
|
146 | 119 | // If the number of pointers down is less than two then reset diff tracker |
147 | 120 | if (evCache.length < 2) { |
|
0 commit comments