| 172 | } |
| 173 | |
| 174 | function handleTouchMove(e) { |
| 175 | if (mode == TOUCHPAN) { |
| 176 | const t = findTouch(e.changedTouches, touchid); |
| 177 | if (t == null) return; |
| 178 | if (e.touches.length != 1) { |
| 179 | setMode(IDLE); |
| 180 | return; |
| 181 | } |
| 182 | panMove(t.clientX, t.clientY); |
| 183 | e.preventDefault(); |
| 184 | } else if (mode == TOUCHZOOM) { |
| 185 | // Get two touches; new gap; rescale to ratio. |
| 186 | const t1 = findTouch(e.touches, touchid); |
| 187 | const t2 = findTouch(e.touches, touchid2); |
| 188 | if (t1 == null || t2 == null) return; |
| 189 | const gap = touchGap(t1, t2); |
| 190 | rescale(initScale * gap / initGap, centerPoint); |
| 191 | e.preventDefault(); |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | function handleTouchEnd(e) { |
| 196 | if (mode == TOUCHPAN) { |