* Applies a `transform` to the root element, taking into account any existing transforms on it. * @param x New transform value along the X axis. * @param y New transform value along the Y axis.
(x: number, y: number)
| 1388 | * @param y New transform value along the Y axis. |
| 1389 | */ |
| 1390 | private _applyRootElementTransform(x: number, y: number) { |
| 1391 | const scale = 1 / this.scale; |
| 1392 | const transform = getTransform(x * scale, y * scale); |
| 1393 | const styles = this._rootElement.style; |
| 1394 | |
| 1395 | // Cache the previous transform amount only after the first drag sequence, because |
| 1396 | // we don't want our own transforms to stack on top of each other. |
| 1397 | // Should be excluded none because none + translate3d(x, y, x) is invalid css |
| 1398 | if (this._initialTransform == null) { |
| 1399 | this._initialTransform = |
| 1400 | styles.transform && styles.transform != 'none' ? styles.transform : ''; |
| 1401 | } |
| 1402 | |
| 1403 | // Preserve the previous `transform` value, if there was one. Note that we apply our own |
| 1404 | // transform before the user's, because things like rotation can affect which direction |
| 1405 | // the element will be translated towards. |
| 1406 | styles.transform = combineTransforms(transform, this._initialTransform); |
| 1407 | } |
| 1408 | |
| 1409 | /** |
| 1410 | * Applies a `transform` to the preview, taking into account any existing transforms on it. |
no test coverage detected