1. 程式人生 > >監聽ios自帶返回功能

監聽ios自帶返回功能

self .com 滾動 get pre start top == sel

//1.一開始用這段代碼,結果發現滾動都失效了,如果頁面大於屏幕高度將無法滾動至底部,所以淘汰
// document.addEventListener(‘touchmove‘, function(e) {
//  e.preventDefault();
// });
//2.改良後的代碼,將該代碼直接放在index.html文件下即可
let self = this;
document.addEventListener(touchstart, (e) => {
  self.moveY = e.targetTouches[0].pageY;
})
document.addEventListener(
touchmove, (e) => { e.preventDefault(); let moveWidth = self.moveY - e.targetTouches[0].pageY; if (moveWidth !== 0) { document.body.scrollTop += moveWidth; } })

摘自:https://www.2cto.com/kf/201704/623753.html

監聽ios自帶返回功能