闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
658 B

  1. import detectPassiveEvents from 'detect-passive-events';
  2. const LAYOUT_BREAKPOINT = 630;
  3. export function isMobile(width) {
  4. return width <= LAYOUT_BREAKPOINT;
  5. };
  6. const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
  7. let userTouching = false;
  8. let listenerOptions = detectPassiveEvents.hasSupport ? { passive: true } : false;
  9. function touchListener() {
  10. userTouching = true;
  11. window.removeEventListener('touchstart', touchListener, listenerOptions);
  12. }
  13. window.addEventListener('touchstart', touchListener, listenerOptions);
  14. export function isUserTouching() {
  15. return userTouching;
  16. }
  17. export function isIOS() {
  18. return iOS;
  19. };