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

Method scrollTo

src/cdk/scrolling/scrollable.ts:88–127  ·  view source on GitHub ↗

* Scrolls to the specified offsets. This is a normalized version of the browser's native scrollTo * method, since browsers are not consistent about what scrollLeft means in RTL. For this method * left and right always refer to the left and right side of the scrolling container irrespective

(options: ExtendedScrollToOptions)

Source from the content-addressed store, hash-verified

86 * @param options specified the offsets to scroll to.
87 */
88 scrollTo(options: ExtendedScrollToOptions): void {
89 const el = this.elementRef.nativeElement;
90 const isRtl = this.dir && this.dir.value == 'rtl';
91
92 // Rewrite start & end offsets as right or left offsets.
93 if (options.left == null) {
94 options.left = isRtl ? options.end : options.start;
95 }
96
97 if (options.right == null) {
98 options.right = isRtl ? options.start : options.end;
99 }
100
101 // Rewrite the bottom offset as a top offset.
102 if (options.bottom != null) {
103 (options as _Without<_Bottom> & _Top).top =
104 el.scrollHeight - el.clientHeight - options.bottom;
105 }
106
107 // Rewrite the right offset as a left offset.
108 if (isRtl && getRtlScrollAxisType() != RtlScrollAxisType.NORMAL) {
109 if (options.left != null) {
110 (options as _Without<_Left> & _Right).right =
111 el.scrollWidth - el.clientWidth - options.left;
112 }
113
114 if (getRtlScrollAxisType() == RtlScrollAxisType.INVERTED) {
115 options.left = options.right;
116 } else if (getRtlScrollAxisType() == RtlScrollAxisType.NEGATED) {
117 options.left = options.right ? -options.right : options.right;
118 }
119 } else {
120 if (options.right != null) {
121 (options as _Without<_Right> & _Left).left =
122 el.scrollWidth - el.clientWidth - options.right;
123 }
124 }
125
126 this._applyScrollToOptions(options);
127 }
128
129 private _applyScrollToOptions(options: ScrollToOptions): void {
130 const el = this.elementRef.nativeElement;

Callers 5

ripple.spec.tsFile · 0.80
tab-group.spec.tsFile · 0.80
scrollToOffsetMethod · 0.80
_applyScrollToOptionsMethod · 0.80
scrollable.spec.tsFile · 0.80

Calls 2

_applyScrollToOptionsMethod · 0.95
getRtlScrollAxisTypeFunction · 0.90

Tested by

no test coverage detected