87 lines
2.1 KiB
HTML
87 lines
2.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Document</title>
|
|
<link rel="stylesheet" href="http:///at.alicdn.com/t/font_3445167_ub2ivnoluaa.css">
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
padding: 0;
|
|
width: 100%;
|
|
height: 1000px;
|
|
}
|
|
|
|
.iconfont {
|
|
font-size: 50px;
|
|
position: absolute;
|
|
top: 0px;
|
|
}
|
|
|
|
.header {
|
|
width: 100%;
|
|
height: 50px;
|
|
background: red;
|
|
overflow: hidden;
|
|
position: relative;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="header">
|
|
<i class="iconfont icon-shuaxin"></i>
|
|
</div>
|
|
</body>
|
|
<script>
|
|
var header = $(".header");
|
|
var content = $("content");
|
|
var startY = 0;
|
|
|
|
$("body").onscroll = function (v) {
|
|
if (document.documentElement.scrollTop == 0) {
|
|
//绑定下拉事件
|
|
v.addEventListener('touchstart', function (e) {
|
|
startY = e.targetTouches[0].screenY;
|
|
console.log("startY:", startY);
|
|
console.log("touchstart:", e);
|
|
})
|
|
|
|
v.addEventListener('touchmove', function (e) {
|
|
var moveY = e.targetTouches[0].screenY;
|
|
console.log("moveY:", moveY);
|
|
// 下滑
|
|
if (startY > moveY) {
|
|
console.log("下滑:",);
|
|
} else {
|
|
console.log("上滑");
|
|
}
|
|
})
|
|
|
|
v.addEventListener('touchend', function (e) {
|
|
console.log("touchend:", e);
|
|
var endY = e.changedTouches[0].screenY;
|
|
})
|
|
console.log("到顶了:", header);
|
|
} else {
|
|
// header.className = "header"
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function $(className) {
|
|
return document.querySelector(className)
|
|
}
|
|
</script>
|
|
|
|
</html> |