(event: TouchEvent)
| 159 | }; |
| 160 | |
| 161 | const onTouchMove = (event: TouchEvent) => { |
| 162 | if (!tracking) { |
| 163 | return; |
| 164 | } |
| 165 | const y = event.touches[0].clientY; |
| 166 | dy = y - startY; |
| 167 | const dt = event.timeStamp - lastTime; |
| 168 | if (dt > 0) { |
| 169 | velocity = (y - lastY) / dt; |
| 170 | } |
| 171 | lastY = y; |
| 172 | lastTime = event.timeStamp; |
| 173 | |
| 174 | if (!dragging) { |
| 175 | const dx = (event.touches[0].clientX ?? 0) - startX; |
| 176 | if (Math.abs(dx) < 6 && Math.abs(dy) < 6) { |
| 177 | return; |
| 178 | } |
| 179 | // The first move past the slop picks the axis: sideways is a scroll |
| 180 | // of the row under the finger, not a drag, until the finger lifts. |
| 181 | if (Math.abs(dx) >= Math.abs(dy)) { |
| 182 | tracking = false; |
| 183 | return; |
| 184 | } |
| 185 | // Upward with nowhere to grow is the content's scroll, not a drag. |
| 186 | if (dy < 0 && (isExpanded() || panel.offsetHeight >= measureFull() - 1)) { |
| 187 | tracking = false; |
| 188 | return; |
| 189 | } |
| 190 | beginDrag(); |
| 191 | } |
| 192 | event.preventDefault(); |
| 193 | |
| 194 | const base = startedExpanded ? fullHeight : restHeight; |
| 195 | // Above the resting height the finger changes the sheet's height; below |
| 196 | // it the sheet rides down whole. |
| 197 | const wanted = base - dy; |
| 198 | if (wanted >= restHeight) { |
| 199 | const height = Math.min(fullHeight, wanted); |
| 200 | style.height = `${height}px`; |
| 201 | style.transform = ''; |
| 202 | style.setProperty('--sheet-gap', `${fullHeight - height}px`); |
| 203 | } else { |
| 204 | style.height = `${restHeight}px`; |
| 205 | style.transform = `translateY(${restHeight - wanted}px)`; |
| 206 | } |
| 207 | }; |
| 208 | |
| 209 | const onTouchEnd = (event: TouchEvent) => { |
| 210 | if (!tracking) { |
nothing calls this directly
no test coverage detected