Gets the pointer position on the page, accounting for any position constraints.
(point: Point)
| 1299 | |
| 1300 | /** Gets the pointer position on the page, accounting for any position constraints. */ |
| 1301 | private _getConstrainedPointerPosition(point: Point): Point { |
| 1302 | const dropContainerLock = this._dropContainer ? this._dropContainer.lockAxis : null; |
| 1303 | let {x, y} = this.constrainPosition |
| 1304 | ? this.constrainPosition(point, this, this._initialDomRect!, this._pickupPositionInElement) |
| 1305 | : point; |
| 1306 | |
| 1307 | if (this.lockAxis === 'x' || dropContainerLock === 'x') { |
| 1308 | y = |
| 1309 | this._pickupPositionOnPage.y - |
| 1310 | (this.constrainPosition ? this._pickupPositionInElement.y : 0); |
| 1311 | } else if (this.lockAxis === 'y' || dropContainerLock === 'y') { |
| 1312 | x = |
| 1313 | this._pickupPositionOnPage.x - |
| 1314 | (this.constrainPosition ? this._pickupPositionInElement.x : 0); |
| 1315 | } |
| 1316 | |
| 1317 | if (this._boundaryRect) { |
| 1318 | // If not using a custom constrain we need to account for the pickup position in the element |
| 1319 | // otherwise we do not need to do this, as it has already been accounted for |
| 1320 | const {x: pickupX, y: pickupY} = !this.constrainPosition |
| 1321 | ? this._pickupPositionInElement |
| 1322 | : {x: 0, y: 0}; |
| 1323 | |
| 1324 | const boundaryRect = this._boundaryRect; |
| 1325 | const {width: previewWidth, height: previewHeight} = this._getPreviewRect(); |
| 1326 | const minY = boundaryRect.top + pickupY; |
| 1327 | const maxY = boundaryRect.bottom - (previewHeight - pickupY); |
| 1328 | const minX = boundaryRect.left + pickupX; |
| 1329 | const maxX = boundaryRect.right - (previewWidth - pickupX); |
| 1330 | |
| 1331 | x = clamp(x, minX, maxX); |
| 1332 | y = clamp(y, minY, maxY); |
| 1333 | } |
| 1334 | |
| 1335 | return {x, y}; |
| 1336 | } |
| 1337 | |
| 1338 | /** Updates the current drag delta, based on the user's current pointer position on the page. */ |
| 1339 | private _updatePointerDirectionDelta(pointerPositionOnPage: Point) { |
no test coverage detected