zoukankan      html  css  js  c++  java
  • 手机触屏滑动图片切换插件swiper.js

    今天给大家分享一款手机触屏滑动图片切换插件swiper.js是一款swiper手机触屏滑动图片幻灯片,适合各种尺寸。效果图如下:

    在线预览   源码下载

    实现的代码。

    html代码:

      <div style="max- 640px; margin: 0 auto;">
            <div class="swiper-container">
                <div class="swiper-wrapper">
                    <div class="swiper-slide">
                        <img src="images/zhiling1.jpg"></div>
                    <div class="swiper-slide">
                        <img src="images/zhiling2.jpg"></div>
                    <div class="swiper-slide">
                        <img src="images/zhiling3.jpg"></div>
                    <div class="swiper-slide">
                        <img src="images/zhiling4.jpg"></div>
                    <div class="swiper-slide">
                        <img src="images/zhiling5.jpg"></div>
                    <div class="swiper-slide">
                        <img src="images/zhiling6.jpg"></div>
                    <div class="swiper-slide">
                        <img src="images/zhiling7.jpg"></div>
                </div>
            </div>
        </div>

    js代码:

    function fixPagesHeight() {
    
        $('.swiper-slide,.swiper-container').css({
    
            height: $(window).height(),
    
        })
    
    }
    
    $(window).on('resize', function() {
    
        fixPagesHeight();
    
    })
    
    fixPagesHeight();
    
    
    
    
    
    var mySwiper = new Swiper('.swiper-container', {
    
    
    
        direction: 'vertical',
    
        mousewheelControl: true,
    
        watchSlidesProgress: true,
    
        onInit: function(swiper) {
    
            swiper.myactive = 0;
    
            
    
        },
    
        onProgress: function(swiper) {
    
            for (var i = 0; i < swiper.slides.length; i++) {
    
                var slide = swiper.slides[i];
    
                var progress = slide.progress;
    
                var translate, boxShadow;
    
    
    
                translate = progress * swiper.height * 0.8;
    
                scale = 1 - Math.min(Math.abs(progress * 0.2), 1);
    
                boxShadowOpacity = 0;
    
    
    
                slide.style.boxShadow = '0px 0px 10px rgba(0,0,0,' + boxShadowOpacity + ')';
    
    
    
                if (i == swiper.myactive) {
    
                    es = slide.style;
    
                    es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = 'translate3d(0,' + (translate) + 'px,0) scale(' + scale + ')';
    
                    es.zIndex=0;
    
    
    
    
    
                }else{
    
                    es = slide.style;
    
                    es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform ='';
    
                    es.zIndex=1;
    
                    
    
                }
    
    
    
            }
    
    
    
        },
    
    
    
    
    
        onTransitionEnd: function(swiper, speed) {
    
            for (var i = 0; i < swiper.slides.length; i++) {
    
            //    es = swiper.slides[i].style;
    
            //    es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = '';
    
    
    
            //    swiper.slides[i].style.zIndex = Math.abs(swiper.slides[i].progress);
    
    
    
                
    
            }
    
    
    
            swiper.myactive = swiper.activeIndex;
    
    
    
        },
    
        onSetTransition: function(swiper, speed) {
    
    
    
            for (var i = 0; i < swiper.slides.length; i++) {
    
                //if (i == swiper.myactive) {
    
    
    
                    es = swiper.slides[i].style;
    
                    es.webkitTransitionDuration = es.MsTransitionDuration = es.msTransitionDuration = es.MozTransitionDuration = es.OTransitionDuration = es.transitionDuration = speed + 'ms';
    
                //}
    
            }
    
    
    
        }
    
    
    
    });

    via:http://www.w2bc.com/Article/33095

  • 相关阅读:
    51nod 1621 花钱买车牌 优先队列
    最大字段和 51nod 1049 水水水水水水水水水水水水
    大数相乘 51nod 1027 水题
    逆序数 51nod 1019 归并 分治
    最长公共子序列 LCS 递归 dp 51Nod 1006
    vc6 字体设置
    自行车维护大全(zz)
    DirectX 9.0 3D游戏开发编程基础 [书评](zz)
    二维线段树
    latex 引用文献 bib
  • 原文地址:https://www.cnblogs.com/liaohuolin/p/4434656.html
Copyright © 2011-2022 走看看