* Event handler for touchmove event * @param {TouchEvent} e
(e)
| 207 | * @param {TouchEvent} e |
| 208 | */ |
| 209 | function touchmove(e) { |
| 210 | if (contextmenu || touchMoved === false) return; |
| 211 | |
| 212 | const $el = e.target; |
| 213 | const { $row1, $row2 } = quickTools; |
| 214 | const { clientX } = e.touches[0]; |
| 215 | |
| 216 | if (moveX === 0) { |
| 217 | moveX = clientX; |
| 218 | return; |
| 219 | } |
| 220 | |
| 221 | const diff = moveX - clientX; |
| 222 | if (touchMoved === undefined) { |
| 223 | if (Math.abs(diff) > appSettings.value.touchMoveThreshold) { |
| 224 | touchMoved = true; |
| 225 | } else { |
| 226 | if ($row) { |
| 227 | const movedX = $row.scrollLeft % $row.clientWidth; |
| 228 | // $row.scrollBy(-movedX, 0); |
| 229 | // scrollBy is not working on mobile |
| 230 | $row.scrollLeft -= movedX; |
| 231 | } |
| 232 | touchMoved = false; |
| 233 | return; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | movedX += diff; |
| 238 | |
| 239 | if (!$row) { |
| 240 | if ($row1?.contains($el)) { |
| 241 | $row = $row1; |
| 242 | } else if ($row2?.contains($el)) { |
| 243 | $row = $row2; |
| 244 | } |
| 245 | |
| 246 | slide = Number.parseInt($row.scrollLeft / $row.clientWidth, 10); |
| 247 | } |
| 248 | |
| 249 | if ($row) { |
| 250 | $row.style.scrollBehavior = "unset"; |
| 251 | $row.scrollLeft += diff; |
| 252 | } |
| 253 | |
| 254 | if (!active) $touchstart.classList.remove("active"); |
| 255 | moveX = clientX; |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * Event handler for touchend event |