基于swiper的图片视频左右滑块特效代码

所属分类: 网页特效-图片特效&上传    2023-12-18 11:56:31

基于swiper的图片视频左右滑块特效代码 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

基于swiper的图片视频左右滑块特效代码(共12个文件)

    • index.html

使用方法

//set video duration
const videos = document.querySelectorAll('.story__slide video');
videos.forEach(video => {
	$(video).parent('.story__slide').attr('data-swiper-autoplay', video.duration * 1000);
});

const slider = new Swiper(".story__slider", {
	speed: 1,
	watchSlidesProgress: true,
	loop: true,
	autoplay: {
		delay: 15000,
		disableOnInteraction: false
	},
	slidesPerView: 1,
	navigation: {
		nextEl: ".story__next",
		prevEl: ".story__prev",
	},
	pagination: {
		el: '.story__pagination',
		renderBullet: function (index, className) {
			return '<div class="' + className + '"> <div class="swiper-pagination-progress"></div> </div>';
		}
	},
	on: {
		autoplayTimeLeft(swiper, time, progress) {
			let currentSlide = document.querySelectorAll('.story__slider .swiper-slide')[swiper.activeIndex]
			let currentBullet = document.querySelectorAll('.story__slider .swiper-pagination-progress')[swiper.realIndex]
			let fullTime = currentSlide.dataset.swiperAutoplay ? parseInt(currentSlide.dataset.swiperAutoplay) : swiper.params.autoplay.delay;

			let percentage = Math.min( Math.max ( parseFloat(((fullTime - time) * 100 / fullTime).toFixed(1)), 0), 100) + '%';

			gsap.set(currentBullet, {width: percentage});
		},
		transitionEnd(swiper) {
			let allBullets = $('.story__slider .swiper-pagination-progress');
			let bulletsBefore = allBullets.slice(0, swiper.realIndex);
			let bulletsAfter = allBullets.slice(swiper.realIndex, allBullets.length);
			if(bulletsBefore.length) {gsap.set(bulletsBefore, {width: '100%'})}
			if(bulletsAfter.length) {gsap.set(bulletsAfter, {width: '0%'})}

			let activeSlide = document.querySelectorAll('.story__slider .swiper-slide')[swiper.realIndex];
			if (activeSlide.querySelector('video')) {
				activeSlide.querySelector('video').currentTime = 0;
			}
		},
	}
});

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 图片特效&上传

jquery支持鼠标滚轮键盘单击控制的内容滑块插件

一个水平内容滑块,可使用鼠标滚轮、键盘中的箭头或鼠标单击按钮和分页控件在幻灯片中滑动。
  图片特效&上传
 5709  0

jquery带视差效果的焦点图插件

一款切换时带视差效果的幻灯片插件,鼠标点击左右按钮可执行图片切换,还支持拖拽或移动端触屏滑动。
  图片特效&上传
 1673  0

原生js写的手机端touch触屏图片切换

电脑端鼠标点击无效,需在移动端或手机端触屏才能触发,大家试试!
  图片特效&上传
 9751  0

jquery简单背景图片视差滚动插件

鼠标拉动页面滚动条,触发图片视差滚动特效,体验很棒!
  图片特效&上传
 8724  0

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论