| 415 | }; |
| 416 | |
| 417 | const onPointerUp = (event: React.PointerEvent<HTMLDivElement>) => { |
| 418 | const { current } = pointer; |
| 419 | if (!current || current.id !== event.pointerId) { |
| 420 | return; |
| 421 | } |
| 422 | const { moved } = current; |
| 423 | const target = tabAt(event.clientX); |
| 424 | // A finger that lifts away from the bar, above or below it, cancels, as |
| 425 | // the iOS tab bar does. |
| 426 | const rect = trackRef.current?.getBoundingClientRect(); |
| 427 | const away = |
| 428 | !!rect && |
| 429 | (event.clientY < rect.top - cluster.cancelDistance || |
| 430 | event.clientY > rect.bottom + cluster.cancelDistance); |
| 431 | endDrag(away || !target ? activeIndex : target.index); |
| 432 | if (!target || away || (!moved && event.pointerType !== 'touch')) { |
| 433 | return; |
| 434 | } |
| 435 | // A click may still follow the release; the pointer already chose. |
| 436 | suppressClick.current = true; |
| 437 | window.setTimeout(() => { |
| 438 | suppressClick.current = false; |
| 439 | }, motion.snap); |
| 440 | const tab = tabs[target.index]; |
| 441 | if (!activate(tab)) { |
| 442 | moveShell(router, ShellMove.Switch, () => router.push(tab.href)); |
| 443 | } |
| 444 | }; |
| 445 | |
| 446 | const onClickCapture = (event: React.MouseEvent) => { |
| 447 | if (suppressClick.current) { |