• 鼠标滚轮滚动切换内容


    在这里插入图片描述

    swiper.js
    在这里插入图片描述

    swiper.js和swiper.css资源文件:
    链接: https://pan.baidu.com/s/1roJSDBRkq_oL82Q2-d1Xew 提取码: ec5j
    在这里插入图片描述

    使用:

    .swiper {
        width: 100%;
        height: calc(100vh + 100px);
    }
    
    .swiper-wrapper {
        width: 100%;
        min-width: 1420px;
    }
    
    .swiper-slide .box {
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .swiper-slide .box-left img {
        width: 64px;
        height: 64px;
    }
    
    .swiper-slide .box-right img {
        height: 500px;
        width: 740px;
    }
    
    .swiper-pagination-vertical.swiper-pagination-bullets, .swiper-vertical > .swiper-pagination-bullets {
        left: 0;
        right: auto;
        transform: translateX(200px);
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    <div class="swiper mySwiper">
        <div class="swiper-wrapper">
            <div class="swiper-slide">
                <div class="box">
                	
                 div>
            div>
            <div class="swiper-slide">
                <div class="box">
                   
                div>
            div>
            <div class="swiper-slide">
                <div class="box">
                    
                div>
            div>
            <div class="swiper-slide">
                <div class="box">
                    
                div>
            div>
        div>
        
        <div class="swiper-pagination">div>
    div>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    // js 动画
    var mySwiper = $('.mySwiper');
    
    var swiper = new Swiper(".mySwiper", {
        direction: "vertical",
        slidesPerView: 1,
        spaceBetween: 30,
        mousewheel: true,
        pagination: {
            el: ".swiper-pagination",
            clickable: true,
        },
        on: {
            slidePrevTransitionEnd: function () {
                var index = swiper.activeIndex;
                index === 0 ? mySwiper.css('pointer-events', 'none') : mySwiper.css('pointer-events', 'auto');
            },
            slideNextTransitionEnd: function () {
                swiper.isEnd ? mySwiper.css('pointer-events', 'none') : mySwiper.css('pointer-events', 'auto');
            },
        }
    });
    
    window.onmousewheel = tran;
    
    function tran(ev) {
        var ev = ev || window.event;
        var top = document.documentElement.scrollTop;
        var index = swiper.activeIndex;
        if (ev.wheelDelta < 0) {
            if (top > 940) {
                unScroll();
                $('.header').css({'position': 'fixed', 'z-index': '9'});
            }
            if(index === 3){
                removeUnScroll();
            }
            console.log('向下滚动', document.documentElement.scrollTop)
        } else {
            if (top < 980) {
                unScroll();
                mySwiper.css('pointer-events', 'auto');
            }
            if(index === 0){
                removeUnScroll();
                $('.header').css({'position': 'relative'});
            }
            console.log('向上滚动', document.documentElement.scrollTop)
        }
    }
    
    function unScroll() {
        var top = $(document).scrollTop();
        $(document).on('scroll.unable',function (e) {
            $(document).scrollTop(top);
        })
    }
    
    function removeUnScroll() {
        $(document).unbind("scroll.unable");
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
  • 相关阅读:
    C++ 程序员入门需要多久,怎样才能学好?
    《数据库系统概念》-01 初级SQL,基础SQL语句
    渗透测试-命令执行漏洞
    Effective C++ 规则31:将文件间的编译依存关系降至最低
    20220719_Filter_Listener_AJAX_Axios的用法
    freeswitch的mod_curl模块
    23.2 时间-定时器、格式化时间
    【论文笔记】—低照度图像增强—Unsupervised—EnlightenGAN—2019-TIP
    《idea 骚操作》
    选择致敬持续奋斗背后的精神——对话威尔价值观【第四期】
  • 原文地址:https://blog.csdn.net/qq_45832807/article/details/127571287