MCPcopy Index your code
hub / github.com/angular/components / _addOffset

Method _addOffset

src/material/tooltip/tooltip.ts:608–623  ·  view source on GitHub ↗

Adds the configured offset to a position. Used as a hook for child classes.

(position: ConnectedPosition)

Source from the content-addressed store, hash-verified

606
607 /** Adds the configured offset to a position. Used as a hook for child classes. */
608 protected _addOffset(position: ConnectedPosition): ConnectedPosition {
609 const offset = UNBOUNDED_ANCHOR_GAP;
610 const isLtr = !this._dir || this._dir.value == 'ltr';
611
612 if (position.originY === 'top') {
613 position.offsetY = -offset;
614 } else if (position.originY === 'bottom') {
615 position.offsetY = offset;
616 } else if (position.originX === 'start') {
617 position.offsetX = isLtr ? -offset : offset;
618 } else if (position.originX === 'end') {
619 position.offsetX = isLtr ? offset : -offset;
620 }
621
622 return position;
623 }
624
625 /**
626 * Returns the origin position and a fallback position based on the user's position preference.

Callers 1

_updatePositionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected