| 149 | } |
| 150 | |
| 151 | function handleTouchStart(e) { |
| 152 | if (mode == IDLE && e.changedTouches.length == 1) { |
| 153 | // Start touch based panning |
| 154 | const t = e.changedTouches[0]; |
| 155 | setMode(TOUCHPAN); |
| 156 | touchid = t.identifier; |
| 157 | panStart(t.clientX, t.clientY); |
| 158 | e.preventDefault(); |
| 159 | } else if (mode == TOUCHPAN && e.touches.length == 2) { |
| 160 | // Start pinch zooming |
| 161 | setMode(TOUCHZOOM); |
| 162 | const t1 = e.touches[0]; |
| 163 | const t2 = e.touches[1]; |
| 164 | touchid = t1.identifier; |
| 165 | touchid2 = t2.identifier; |
| 166 | initScale = currentScale; |
| 167 | initGap = touchGap(t1, t2); |
| 168 | centerPoint = toSvg((t1.clientX + t2.clientX) / 2, |
| 169 | (t1.clientY + t2.clientY) / 2); |
| 170 | e.preventDefault(); |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | function handleTouchMove(e) { |
| 175 | if (mode == TOUCHPAN) { |