logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

is_mobile.js (658B)


  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. };