console
var content = document.querySelector('main');
var startY;
content.addEventListener('touchstart', function(e) {
startY = e.touches[0].clientY;
});
content.addEventListener('touchmove', function(e) {
var status = '11';
var ele = this;
var currentY = e.touches[0].clientY;
if (ele.scrollTop === 0) {
status = ele.offsetHeight >= ele.scrollHeight ? '00': '01';
} else if (ele.scrollTop + ele.offsetHeight >= ele.scrollHeight) {
status = '10';
}
if (status != '11') {
var direction = currentY - startY > 0 ? '10': '01';
if (! (parseInt(status, 2) & parseInt(direction, 2))) {
console.log(status);
e.preventDefault();
}
}
});
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
</meta>
<header>
<span><</span>
<span>...</span>
</header>
<main>
<div class="content">
</div>
</main>
<footer>
<input type="text" placeholder="Input..." />
<button class="submit">
提交
</button>
</footer>
body {
overflow: hidden;
max-width: 750px;
background-color: #f8f8f8;
}
header,
footer,
main {
display: block;
}
header {
position: fixed;
height: 50px;
left: 0;
right: 0;
top: 0;
padding: 0 10px;
display: flex;
align-items: center;
justify-content: space-between;
box-shadow: 0 0 1px 0 rgba(0, 0, 0, .2);
}
footer {
position: fixed;
height: 34px;
left: 0;
right: 0;
bottom: 0;
padding: 0 10px;
display: flex;
align-items: center;
justify-content: space-between;
}
footer input {
height: 100%;
border: 0;
outline: 0;
flex: 1;
margin-right: 10px;
}
main {
position: absolute;
top: 50px;
bottom: 34px;
left: 0;
right: 0;
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
}
main .content {
height: 2000px;
background: linear-gradient(180deg, red, blue);
}