* On mouse or touch move * @param {MouseEvent|TouchEvent} e * @returns
(e)
| 157 | * @returns |
| 158 | */ |
| 159 | function onDrag(e) { |
| 160 | if (e instanceof Event) { |
| 161 | e.preventDefault(); |
| 162 | e.stopPropagation(); |
| 163 | e.stopImmediatePropagation(); |
| 164 | } |
| 165 | |
| 166 | const { clientX, clientY } = getClientPos(e); |
| 167 | |
| 168 | tabLeft = clientX - offsetX; |
| 169 | tabTop = clientY - offsetY; |
| 170 | |
| 171 | $tabClone.style.transform = `translate3d(${tabLeft}px, ${tabTop}px, 0)`; |
| 172 | updateDragPreview(clientX, clientY); |
| 173 | |
| 174 | if ($parent.scrollWidth === $parent.clientWidth) return; |
| 175 | |
| 176 | const scroll = getScroll(); |
| 177 | // if can scroll and already scrolling return |
| 178 | // or if can't scroll and not scrolling return |
| 179 | if (!!scroll === !!animationFrame) return; |
| 180 | // if can't scroll and scrolling clear interval |
| 181 | if (!scroll && animationFrame) { |
| 182 | cancelAnimationFrame(animationFrame); |
| 183 | animationFrame = null; |
| 184 | return; |
| 185 | } |
| 186 | |
| 187 | scrollContainer(); |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * Cancels the drag |
nothing calls this directly
no test coverage detected