Updates the current drag delta, based on the user's current pointer position on the page.
(pointerPositionOnPage: Point)
| 1337 | |
| 1338 | /** Updates the current drag delta, based on the user's current pointer position on the page. */ |
| 1339 | private _updatePointerDirectionDelta(pointerPositionOnPage: Point) { |
| 1340 | const {x, y} = pointerPositionOnPage; |
| 1341 | const delta = this._pointerDirectionDelta; |
| 1342 | const positionSinceLastChange = this._pointerPositionAtLastDirectionChange; |
| 1343 | |
| 1344 | // Amount of pixels the user has dragged since the last time the direction changed. |
| 1345 | const changeX = Math.abs(x - positionSinceLastChange.x); |
| 1346 | const changeY = Math.abs(y - positionSinceLastChange.y); |
| 1347 | |
| 1348 | // Because we handle pointer events on a per-pixel basis, we don't want the delta |
| 1349 | // to change for every pixel, otherwise anything that depends on it can look erratic. |
| 1350 | // To make the delta more consistent, we track how much the user has moved since the last |
| 1351 | // delta change and we only update it after it has reached a certain threshold. |
| 1352 | if (changeX > this._config.pointerDirectionChangeThreshold) { |
| 1353 | delta.x = x > positionSinceLastChange.x ? 1 : -1; |
| 1354 | positionSinceLastChange.x = x; |
| 1355 | } |
| 1356 | |
| 1357 | if (changeY > this._config.pointerDirectionChangeThreshold) { |
| 1358 | delta.y = y > positionSinceLastChange.y ? 1 : -1; |
| 1359 | positionSinceLastChange.y = y; |
| 1360 | } |
| 1361 | |
| 1362 | return delta; |
| 1363 | } |
| 1364 | |
| 1365 | /** Toggles the native drag interactions, based on how many handles are registered. */ |
| 1366 | private _toggleNativeDragInteractions() { |