我正在尝试使用Sidr.js在移动设备上为菜单创建滑动关闭。网站正在以Wordpress为主题,以OceanWP为主题进行开发。目前,我只能将其隐藏一次-然后侧边栏菜单不起作用并且无法打开。 Check how it works on production(在移动设备上打开网站,然后单击汉堡包图标)。 我正在使用here中的此代码段。
<!-- For this example I include an external library to handle touch events -->
<script src="//cdn.jsdelivr.net/jquery.touchswipe/1.6.15/jquery.touchSwipe.min.js"></script>
<script>
jQuery(document).ready(function() {
jQuery('body').swipe( {
//Single swipe handler for left swipes
swipeLeft: function () {
jQuery.sidr('close', 'sidr-main');
},
swipeRight: function () {
jQuery.sidr('open', 'sidr-main');
},
//Default is 75px, set to 0 for demo so any distance triggers swipe
threshold: 0
});
});
</script>
有什么解决办法吗?另外,这里有一些控制台错误。
[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See <URL>
jquery.js?ver=1.12.4-wp:2 Uncaught TypeError: Cannot read property 'replace' of undefined
at Function.camelCase (jquery.js?ver=1.12.4-wp:2)
at Function.css (jquery.js?ver=1.12.4-wp:3)
at a.fn.init.<anonymous> (jquery.js?ver=1.12.4-wp:4)
at X (jquery.js?ver=1.12.4-wp:3)
at a.fn.init.css (jquery.js?ver=1.12.4-wp:4)
at m.value (main.min.js?ver=1.8.2:1)
at m.value (main.min.js?ver=1.8.2:1)
at m.value (main.min.js?ver=1.8.2:1)
at m.value (main.min.js?ver=1.8.2:1)
at main.min.js?ver=1.8.2:1