(e: TouchEvent)
| 104 | let scrollable: Element; |
| 105 | let allowTouchMove = false; |
| 106 | let onTouchStart = (e: TouchEvent) => { |
| 107 | // Store the nearest scrollable parent element from the element that the user touched. |
| 108 | let target = getEventTarget(e) as Element; |
| 109 | scrollable = isScrollable(target) ? target : getScrollParent(target, true); |
| 110 | allowTouchMove = false; |
| 111 | |
| 112 | // If the target is selected, don't preventDefault in touchmove to allow user to adjust selection. |
| 113 | let selection = target.ownerDocument.defaultView!.getSelection(); |
| 114 | if (selection && !selection.isCollapsed && selection.containsNode(target, true)) { |
| 115 | allowTouchMove = true; |
| 116 | } |
| 117 | |
| 118 | // If this is a range input, allow touch move to allow user to adjust the slider value |
| 119 | if (e.composedPath().some(el => el instanceof HTMLInputElement && el.type === 'range')) { |
| 120 | allowTouchMove = true; |
| 121 | } |
| 122 | |
| 123 | // If this is a focused input element with a selected range, allow user to drag the selection handles. |
| 124 | if ( |
| 125 | 'selectionStart' in target && |
| 126 | 'selectionEnd' in target && |
| 127 | (target.selectionStart as number) < (target.selectionEnd as number) && |
| 128 | target.ownerDocument.activeElement === target |
| 129 | ) { |
| 130 | allowTouchMove = true; |
| 131 | } |
| 132 | }; |
| 133 | |
| 134 | // Prevent scrolling up when at the top and scrolling down when at the bottom |
| 135 | // of a nested scrollable area, otherwise mobile Safari will start scrolling |
nothing calls this directly
no test coverage detected