【发布时间】:2019-12-16 23:01:13
【问题描述】:
我想在移动设备上水平滑动轮播时禁用网页上的垂直滚动。我正在使用 Owl 旋转木马。
我尝试使用 css overflow: hidden to html, body 但不起作用。 尝试了其他解决方案,但它们不起作用。我试过的代码在下面。
// Tried this but doesn't work
var owl = $j(".owl-carousel");
owl.on('drag.owl.carousel', function(event) {
document.ontouchmove = function (e) {
e.preventDefault()
}
});
owl.on('dragged.owl.carousel', function(event) {
document.ontouchmove = function (e) {
return true
}
});
// Tried this but doesn't work
owl.on('drag.owl.carousel', function(event) {
$('body').css('overflow', 'hidden');
});
owl.on('dragged.owl.carousel', function(event) {
$('body').css('overflow', 'auto');
});
【问题讨论】:
-
如果您向左或向右滑动,它将如何垂直滚动?您会将链接附加到您的网站吗?谢谢。
-
在轮播上向左或向右滑动时,它也会上下移动页面。触摸转盘后,它应该会立即修复。
标签: javascript jquery html css wordpress