如何使用鼠标滚轮同步两个滑块?

问题描述 投票:0回答:1

我在我的页面上使用Swiper滑块。在我的页面上我有两个滑块。我想,当我使用向上滚动时 - 第一个滑块向上,第二个滑块向下。当我使用向下滚动时 - 第一个滑块向下,第二个滑块向上。

我写这个

qazxsw poi qazxsw poi但是这段代码并不好,因为在mac上工作奇怪并且不能在firefox上工作,因为我不使用mousewheel swiper parametr。

https://288757.playcode.io

这是我的滑块没有这个代码https://playcode.io/288757?tabs=style.css&output

如何使用鼠标滚轮同步两个滑块?谢谢!

javascript jquery swiper
1个回答
0
投票

你能试试吗?

        $(window).bind('mousewheel', function(event){
            var width = $(document).width();

            if(width >= 769){
                if (event.originalEvent.wheelDelta > 0 || event.originalEvent.detail < 0) {
                    mySwiper1.slideNext(600);
                    mySwiper2.slidePrev(600);
                }
                else {
                    mySwiper1.slidePrev(600);
                    mySwiper2.slideNext(600);
                }
            }
        });
© www.soinside.com 2019 - 2024. All rights reserved.