MCPcopy Create free account
hub / github.com/ampproject/amphtml / setSize_

Method setSize_

extensions/amp-loader/0.1/amp-loader.js:157–179  ·  view source on GitHub ↗

* Sets the size of the loader based element's size and a few special cases. * @private * @return {undefined}

()

Source from the content-addressed store, hash-verified

155 * @return {undefined}
156 */
157 setSize_() {
158 const sizeClassDefault = 'i-amphtml-new-loader-size-default';
159 const sizeClassSmall = 'i-amphtml-new-loader-size-small';
160 const sizeClassLarge = 'i-amphtml-new-loader-size-large';
161
162 // Ads always get the default spinner regardless of the element size
163 if (this.isAd_()) {
164 return this.loaderRoot_.classList.add(sizeClassDefault);
165 }
166
167 // Other than Ads, small spinner is always used if element is small.
168 if (this.isSmall_()) {
169 return this.loaderRoot_.classList.add(sizeClassSmall);
170 }
171
172 // If host is not small, default size spinner is normally used
173 // unless due to branding guidelines (e.g. Instagram) a larger spinner is
174 // required.
175 if (this.requiresLargeSpinner_()) {
176 return this.loaderRoot_.classList.add(sizeClassLarge);
177 }
178 return this.loaderRoot_.classList.add(sizeClassDefault);
179 }
180
181 /**
182 * Adds the spinner.

Callers 1

Calls 4

isAd_Method · 0.95
isSmall_Method · 0.95
requiresLargeSpinner_Method · 0.95
addMethod · 0.45

Tested by

no test coverage detected