UNPKG

1.16 kBJavaScriptView Raw
1import { readTask, writeTask } from '@stencil/core/internal/client';
2import { c as componentOnReady } from './helpers.js';
3
4const startStatusTap = () => {
5 const win = window;
6 win.addEventListener('statusTap', () => {
7 readTask(() => {
8 const width = win.innerWidth;
9 const height = win.innerHeight;
10 const el = document.elementFromPoint(width / 2, height / 2);
11 if (!el) {
12 return;
13 }
14 const contentEl = el.closest('ion-content');
15 if (contentEl) {
16 new Promise(resolve => componentOnReady(contentEl, resolve)).then(() => {
17 writeTask(async () => {
18 /**
19 * If scrolling and user taps status bar,
20 * only calling scrollToTop is not enough
21 * as engines like WebKit will jump the
22 * scroll position back down and complete
23 * any in-progress momentum scrolling.
24 */
25 contentEl.style.setProperty('--overflow', 'hidden');
26 await contentEl.scrollToTop(300);
27 contentEl.style.removeProperty('--overflow');
28 });
29 });
30 }
31 });
32 });
33};
34
35export { startStatusTap };