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.
42 lines
944 B
42 lines
944 B
(() => {
|
|
// 获取屏幕大小
|
|
const getScreen = () => {
|
|
const width = window.innerWidth;
|
|
const height = window.innerHeight;
|
|
document.body.style = `
|
|
--width:${width}px;
|
|
--height:${height}px;
|
|
`;
|
|
}
|
|
getScreen()
|
|
// 监听屏幕变化
|
|
window.addEventListener('resize', getScreen);
|
|
|
|
// ios 禁用屏幕缩放
|
|
document.documentElement.addEventListener(
|
|
"touchstart",
|
|
function (event) {
|
|
if (event.touches.length > 1) {
|
|
event.preventDefault();
|
|
}
|
|
},
|
|
false
|
|
);
|
|
|
|
var lastTouchEnd = 0;
|
|
document.documentElement.addEventListener(
|
|
"touchend",
|
|
function (event) {
|
|
var now = Date.now();
|
|
if (now - lastTouchEnd <= 300) {
|
|
event.preventDefault();
|
|
}
|
|
lastTouchEnd = now;
|
|
},
|
|
false
|
|
);
|
|
|
|
document.addEventListener("gesturestart", function (event) {
|
|
event.preventDefault();
|
|
});
|
|
})()
|