How to fix problem with clicking event on bxSlider item in Chrome 73?

雨燕双飞 提交于 2019-12-04 03:05:37

Looks like the latest Chrome update made any click inside bxSlider target the container instead the link inside it.

Adding touchEnabled: false to the options disables the swipe behaviour, but solves the click issue. Eg.:

 carouselProduct = $('.slider-pager').bxSlider({
            maxSlides:  3,
            minSlides: 3,
            slideWidth: 90,
            infiniteLoop: false,
            moveSlides: 1,
            slideMargin: 8,
            pager: false,
            nextSelector: '.slider__nav--next',
            prevSelector: '.slider__nav--prev',
            nextText: '→',
            prevText: '←',
            touchEnabled: false
        });

I recommend keeping an eye/contributing to this thread for updates and better solutions: https://github.com/stevenwanderski/bxslider-4/issues/1240

I used the mousedown event instead

if(window.navigator.userAgent.toLowerCase().indexOf("chrome") > 0) {
    $("body").on("mousedown", ".bx-viewport a", function() { 
        if($(this).attr("href") && $(this).attr("href") != "#") {
            window.location=$(this).attr("href"); 
        } 
    }); 
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!