UNPKG

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