( ampDoc, element, elementWidth, elementHeight, startTime = ampDoc.win.Date.now() )
| 26 | * @return {!Element} The loader root element. |
| 27 | */ |
| 28 | export function createLoaderElement( |
| 29 | ampDoc, |
| 30 | element, |
| 31 | elementWidth, |
| 32 | elementHeight, |
| 33 | startTime = ampDoc.win.Date.now() |
| 34 | ) { |
| 35 | // We create the loader root element up front, since it is needed |
| 36 | // synchronously. We create the actual element with animations when the |
| 37 | // service is ready. |
| 38 | const loaderRoot = element.ownerDocument.createElement('div'); |
| 39 | |
| 40 | getLoaderServicePromise(ampDoc, element).then((loaderService) => { |
| 41 | const endTime = ampDoc.win.Date.now(); |
| 42 | const initDelay = endTime - startTime; |
| 43 | loaderService.initializeLoader( |
| 44 | element, |
| 45 | loaderRoot, |
| 46 | initDelay, |
| 47 | elementWidth, |
| 48 | elementHeight |
| 49 | ); |
| 50 | }); |
| 51 | |
| 52 | return loaderRoot; |
| 53 | } |
no test coverage detected