status-tap-42a8af65.js 1.5 KB

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