MCPcopy Create free account
hub / github.com/angular/components / _applyRootElementTransform

Method _applyRootElementTransform

src/cdk/drag-drop/drag-ref.ts:1391–1408  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers 3

setFreeDragPositionMethod · 0.95
DragRefClass · 0.95
_updateOnScrollMethod · 0.95

Calls 2

getTransformFunction · 0.90
combineTransformsFunction · 0.90

Tested by

no test coverage detected