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

Method _applyRootElementTransform

src/cdk/drag-drop/drag-ref.ts:1390–1407  ·  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

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.

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