get-support.js 782 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. let support;
  2. function getMobile() {
  3. if (navigator.userAgent.indexOf('Mobile') > -1) {
  4. return true;
  5. } else {
  6. return false;
  7. }
  8. }
  9. function calcSupport() {
  10. return {
  11. smoothScroll: true,
  12. // #ifdef H5
  13. touch: getMobile(),
  14. // #endif
  15. // #ifndef H5
  16. touch: true,
  17. // #endif
  18. passiveListener: function checkPassiveListener() {
  19. let supportsPassive = false;
  20. try {
  21. const opts = Object.defineProperty({}, 'passive', {
  22. // eslint-disable-next-line
  23. get() {
  24. supportsPassive = true;
  25. }
  26. });
  27. } catch (e) { // No support
  28. }
  29. return supportsPassive;
  30. }(),
  31. gestures: function checkGestures() {
  32. return false;
  33. }()
  34. };
  35. }
  36. function getSupport() {
  37. if (!support) {
  38. support = calcSupport();
  39. }
  40. return support;
  41. }
  42. export {
  43. getSupport
  44. };