javascript - jquery touchswipe 插件在 iOS 上无法正常工作
问题描述
所以基本上我正在开发一个网站,其中滚动事件的默认值被阻止,而是每次滚动都会带你向下或向上到下一个“部分”。这在 PC 和某些手机上非常有效,但在 iOS 上,滚动只是变得一团糟,坦率地说,我没有想法。
我正在使用的移动滚动 API 是 jquery touchSwipe https://github.com/mattbryson/TouchSwipe-Jquery-Plugin
下面的代码是应该完成所有工作的函数。
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
$(window).swipe({
swipe:function(event, direction, distance, duration, fingerCount, fingerData) {
if (scrolling == false && direction === "down") {
scrolling = true;
scrollSection = Math.round($(window).scrollTop()/window.innerHeight);
scrollTo_(event,sections[scrollSection-1]);
setTimeout(function() {
scrolling = false;
}, 1000);
}
else if (scrolling == false && direction === "up") {
scrolling = true;
scrollSection = Math.round($(window).scrollTop()/window.innerHeight);
scrollTo_(event,sections[scrollSection+1]);
setTimeout(function() {
scrolling = false;
}, 1000);
}
}
});
}
如果您有任何问题,请告诉我,我会更新这个问题。
解决方案
你试过这个吗?最近几天在我的网络应用程序中,我研究了 Jquery UI 滑块,这对手机不起作用,所以在附加它之后它就可以工作了。
推荐阅读
- sql - SQL join + group_concat 不返回某些行
- reactjs - 战争未部署到 Tomcat
- javascript - 如何在 Dropzone 中使用 OnSubmit?
- html - 在 Safari iOS 14.2 上自动播放视频 HTML
- sql-server - 进行基准测试时重置缓冲区
- sql - 有没有人成功使用 Antlr v4 为 Hive 生成 javascript
- r - 使用 infer 包模拟多个变量的空分布
- vba - 无法抓取完整的 html 表
- typescript - 如何允许类函数可以为空
- sql-server - 如何在 SQL Server 中将日期参数创建到表名中