status-tap.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*!
  2. * (C) Ionic http://ionicframework.com - MIT License
  3. */
  4. import { readTask, writeTask } from '@stencil/core/internal/client';
  5. import { a as findClosestIonContent, s as scrollToTop } from './index8.js';
  6. import { c as componentOnReady } from './helpers.js';
  7. const 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 = findClosestIonContent(el);
  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 scrollToTop(contentEl, 300);
  30. contentEl.style.removeProperty('--overflow');
  31. });
  32. });
  33. }
  34. });
  35. });
  36. };
  37. export { startStatusTap };