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.

41 lines
944 B

5 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. // ios 禁用屏幕缩放
  15. document.documentElement.addEventListener(
  16. "touchstart",
  17. function (event) {
  18. if (event.touches.length > 1) {
  19. event.preventDefault();
  20. }
  21. },
  22. false
  23. );
  24. var lastTouchEnd = 0;
  25. document.documentElement.addEventListener(
  26. "touchend",
  27. function (event) {
  28. var now = Date.now();
  29. if (now - lastTouchEnd <= 300) {
  30. event.preventDefault();
  31. }
  32. lastTouchEnd = now;
  33. },
  34. false
  35. );
  36. document.addEventListener("gesturestart", function (event) {
  37. event.preventDefault();
  38. });
  39. })()