最新公告
  • 欢迎您光临牛品源码,本站秉承服务宗旨 履行“站长”责任,销售只是起点 服务永无止境!立即加入我们
  • swiper.js手机触屏滑动全屏幻灯片左右切换代码

    基于swiper.js手机触屏滑动全屏幻灯片左右切换代码,带缩略图和左右控制箭头的手机移动端图片轮播插件。

    js代码

    <script src="https://img.x22t.com/file/2020/04/25/04da743bc3e9a5ff82df0171c019474c2401.js"></script> 
    <script>
      	//图片等比例
    	galleryTopHeight()
    	$(window).resize(function(){
    		galleryTopHeight()
    	})
    	
        var galleryTop = new Swiper(".gallery-top-box .gallery-top", {
    	  centeredSlides: true,
    	  autoplay:{
    		delay:4000,
    		disableOnInteraction: false 
    	  },
    	  slidesPerView: "auto",
          spaceBetween: 10,
          navigation: {
            nextEl: ".gallery-top-box .swiper-button-next",
            prevEl: ".gallery-top-box .swiper-button-prev",
          },
    	  scrollbar: {
            el: ".swiper-scrollbar",
            hide: false,
    		draggable: true,
    		dragSize:150,
          }
        });
    	
    	$(".slideshow").click(function(){
    		if($(this).hasClass("pauseed")){
    			//播放
    			$(this).removeClass("pauseed")
    			galleryTop.autoplay.start()
    		}else{
    			//暂停
    			$(this).addClass("pauseed")
    			galleryTop.autoplay.stop()
    			
    		}
    	})
    	
    	galleryTop.scrollbar.$el.css({
    		"bottom":"0px",
    		"background":"none",
    		"height":"5px"
    	});
    	galleryTop.scrollbar.$dragEl.css({
    		"background":"rgba(171,171,171,171.6)"
    	}); 
    	galleryTop.scrollbar.updateSize();
    	
        var galleryThumbs = new Swiper(".gallery-thumbs-box .gallery-thumbs", {
          spaceBetween: 10,
          slidesPerView: "auto",
          touchRatio: 0.2,
    	  navigation: {
            nextEl: ".gallery-thumbs-box .swiper-button-next",
            prevEl: ".gallery-thumbs-box .swiper-button-prev",
          }
        });
    	
    	galleryTop.controller.control = galleryThumbs;
    	
    	<!--注意添加objThumbs,objTop对应的索引值1 ~ N -->
    	var objThumbs = $(".gallery-thumbs .swiper-wrapper .swiper-slide");
    	var objTop = $(".gallery-top .swiper-wrapper .swiper-slide");
    	objThumbs.click(function(e){
    		var currentId = $(this).attr("data-id");
    		for(var i = 0 ; i< objTop.length; i++){
    			if($(objTop[i]).attr("data-id") === currentId){
    				$(objTop[i-1]).addClass("swiper-slide-prev")
    				$(objTop[i-1]).siblings().removeClass("swiper-slide-prev")
    				$(objTop[i]).addClass("swiper-slide-active")
    				$(objTop[i]).siblings().removeClass("swiper-slide-active")
    				$(objTop[i+1]).addClass("swiper-slide-next")
    				$(objTop[i+1]).siblings().removeClass("swiper-slide-next")
    				e.preventDefault();
    				galleryTop.slideTo(i,1000, false);
    			}
    		}
    	})
    	
    	function galleryTopHeight(){
    		//处理图片比例
    		var wh = $(window).height();
    		var headernav_height = $(".headernav").height()
    		var footernav_height = $(".footernav").height()
    		var galleryThumbs_height = $(".gallery-thumbs").height()
    		var galleryTop_height = wh - galleryThumbs_height - headernav_height - footernav_height - 22
    		$(".gallery-top").css("height",galleryTop_height)
    		//缩略图
    		var galleryThumbs_width = $(window).width() - 60
    		$(".gallery-thumbs-box .swiper-container").css("width",galleryThumbs_width)
    		//大图
    		var galleryTop_width = $(window).width() - 80
    		$(".gallery-top-box .swiper-container").css("width",galleryTop_width)
    	}
    
    </script>
    

    发表评论

    售后服务:

    • 售后服务范围 1、商业模板使用范围内问题免费咨询
      2、源码安装、模板安装(一般 ¥50-500)服务答疑仅限SVIP用户
      3、单价超过200元的模板免费一次安装,需提供服务器信息。
      付费增值服务 1、提供dedecms模板、WordPress主题、discuz模板优化等服务请详询在线客服
      2、承接 WordPress、DedeCMS、Discuz 等系统建站、仿站、开发、定制等服务
      3、服务器环境配置(一般 ¥50-500)
      4、网站中毒处理(需额外付费,1000元/次/质保三个月)
      售后服务时间 周一至周日(法定节假日除外) 9:00-23:00
      免责声明 本站所提供的模板(主题/插件)等资源仅供学习交流,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担,有部分资源为网上收集或仿制而来,若模板侵犯了您的合法权益,请来信通知我们(Email: niupinyuanma@foxmail.com),我们会及时删除,给您带来的不便,我们深表歉意!