(el: HTMLElement, durationMs: number)
| 63 | * using the public API `scrollToTop` with a duration. |
| 64 | */ |
| 65 | export const scrollToTop = (el: HTMLElement, durationMs: number): Promise<void> => { |
| 66 | if (isIonContent(el)) { |
| 67 | const content = el as HTMLIonContentElement; |
| 68 | return content.scrollToTop(durationMs); |
| 69 | } |
| 70 | return Promise.resolve( |
| 71 | el.scrollTo({ |
| 72 | top: 0, |
| 73 | left: 0, |
| 74 | behavior: durationMs > 0 ? 'smooth' : 'auto', |
| 75 | }) |
| 76 | ); |
| 77 | }; |
| 78 | |
| 79 | /** |
| 80 | * Scrolls by a specified X/Y distance in the component. If an `ion-content` is found, it will scroll |
no test coverage detected