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.

54 lines
1.3 KiB

11 months ago
  1. (() => {
  2. // 获取屏幕大小
  3. const getScreen = () => {
  4. const width = window.innerWidth;
  5. const height = window.innerHeight;
  6. document.body.style = `
  7. --width:${width}px;
  8. --height:${height}px;
  9. `;
  10. }
  11. getScreen()
  12. // 监听屏幕变化
  13. window.addEventListener('resize', getScreen);
  14. // 加载loading
  15. let publicLoading = document.getElementById('loading');
  16. let publicWidth = 0;
  17. let publicTimerID = null;
  18. publicTimerID = setInterval(() => {
  19. if (publicWidth > 99) {
  20. clearInterval(publicTimerID);
  21. return;
  22. };
  23. publicWidth += 1;
  24. publicLoading.style.width = `${publicWidth}%`;
  25. }, 100);
  26. // ios 禁用屏幕缩放
  27. document.documentElement.addEventListener(
  28. "touchstart",
  29. function (event) {
  30. if (event.touches.length > 1) {
  31. event.preventDefault();
  32. }
  33. },
  34. false
  35. );
  36. var lastTouchEnd = 0;
  37. document.documentElement.addEventListener(
  38. "touchend",
  39. function (event) {
  40. var now = Date.now();
  41. if (now - lastTouchEnd <= 300) {
  42. event.preventDefault();
  43. }
  44. lastTouchEnd = now;
  45. },
  46. false
  47. );
  48. document.addEventListener("gesturestart", function (event) {
  49. event.preventDefault();
  50. });
  51. })()