swiper单屏滚动
.swiper-slide {
overflow: auto;
}
1. 排除某些屏,不滚动
var startScroll, touchStart, touchCurrent;
var aSlide = Array.prototype.slice.call(swiper.slides);
aSlide.forEach(function(item,index){
//按索引排除某些屏
if(index != 2){
item.addEventListener('touchstart', function (e) {
startScroll = this.scrollTop;
touchStart = e.targetTouches[0].pageY;
}, true);
item.addEventListener('touchmove', function (e) {
touchCurrent = e.targetTouches[0].pageY;
var touchesDiff = touchCurrent - touchStart;
var slide = this;
var onlyScrolling =
( slide.scrollHeight > slide.offsetHeight ) && //allow only when slide is scrollable
(
( touchesDiff < 0 && startScroll === 0 ) || //start from top edge to scroll bottom
( touchesDiff > 0 && startScroll === ( slide.scrollHeight - slide.offsetHeight ) ) || //start from bottom edge to scroll top
( startScroll > 0 && startScroll < ( slide.scrollHeight - slide.offsetHeight ) ) //start from the middle
);
if (onlyScrolling) {
e.stopPropagation();
}
}, true);
}
});
2. 按条件排除滚动,消除touchmove影响
var startScroll, touchStart, touchCurrent;
swiper.slides.on('touchstart', function (e) {
startScroll = this.scrollTop;
touchStart = e.targetTouches[0].pageY;
}, true);
swiper.slides.on('touchmove', function (e) {
var slide = this;
//排除条件
if($('#swiperWrapper>.swiper-slide-active').next().length == 0 && document.querySelector(self.template).contains(e.target)){
return;
}
touchCurrent = e.targetTouches[0].pageY;
var touchesDiff = touchCurrent - touchStart;
var onlyScrolling =
( slide.scrollHeight > slide.offsetHeight ) && //allow only when slide is scrollable
(
( touchesDiff < 0 && startScroll === 0 ) || //start from top edge to scroll bottom
( touchesDiff > 0 && startScroll === ( slide.scrollHeight - slide.offsetHeight ) ) || //start from bottom edge to scroll top
( startScroll > 0 && startScroll < ( slide.scrollHeight - slide.offsetHeight ) ) //start from the middle
);
if (onlyScrolling) {
e.stopPropagation();
}
}, true);
swiper单屏滚动的更多相关文章
- 原生js实现单屏滚动
类似于fullpage的单屏滚动,使用原生JS实现,不依赖任何js库: css: html,body {height:100%;} body {margin:0px;} div {height:100 ...
- fullpage 单屏高度超过屏幕高度,实现单屏内可以滚动并解决手机端单屏高度不正确的问题
最近接触了好几次jquery.fullpage.js这个插件,实现整屏的滑动,效果很炫,用fullpage来实现也很简单,但是也碰到了一些问题和大家分享一下 1.单屏高度超过屏幕高度,实现单屏的滑动 ...
- FullPage.js – 轻松实现全屏滚动(单页网站)效果
FullPage.js 是一个简单而易于使用的插件,用来创建全屏滚动网站(也被称为单页网站).除了可以创建全屏滚动效果以外,也可以给网站添加一些水平的滑块效果.能够自适应不同的屏幕尺寸,包括平板电脑和 ...
- 拥抱单页网站! jQuery全屏滚动插件fullPage.js
不知道从什么时候开始,单页网站就悄悄走进人们的视线,尤其是国外的网站,更是钟爱单页网站.制作一个全屏滚动的效果,然后每个滚动页弄一个好看的背景色,配上一些描述性的文字,大家都喜欢这么弄,仿佛逼格瞬间可 ...
- swiper4实现的拥有header和footer的全屏滚动demo/swiper fullpage footer
用swiper4实现的拥有header和footer的全屏滚动demo, <!DOCTYPE html> <html lang="en"> <head ...
- fullpage.js全屏滚动插件使用小结
刚做好公司网站,通过全屏滚动,显著提高了官网的浏览体验.遂总结一下使用fullpage.js的方法.欢迎指正 一. fullpage.js简介 fullpage.js是一套实现浏览器全屏滚动的js插件 ...
- H5全屏滚动专题页最佳实践
1.slip.js + rem.js 主要插件: slip.js github: https://github.com/binnng/slip.js rem.js 插件为阿里淘宝的 rem 实现的基础 ...
- 用JQ仿造百度书籍预售页面的单屏滚页效果
今天的项目需要做到一个介绍页面,我主动提出走单屏滚页的风格,毕竟交互性好,逼格也高,具体效果可以参照百度知道书籍预售页面. 其实现效果就大概是这样的: 还是老样子,所有步骤文件可以从我的Github上 ...
- 《fullPage.js》创建全屏滚动的网站
插件介绍 fullPage.js是一个简单易用的插件,创建全屏滚动的网站(也被称为单页网站).它允许全屏滚动创建网站,以及添加内部滑块. 浏览器兼容性 主要功能 支持鼠标滚动 支持前进后退和键盘控制 ...
随机推荐
- springmvc如何获取参数
请参考这篇文章, 写得比较全面. https://www.cnblogs.com/xiaoxi/p/5695783.html
- 面向对象编程 -------JavaScrip
本文摘要:http://www.liaoxuefeng.com/ 一定明白面向对象的两个基本概念: 类:类是对象的类型模板,例如,定义Student类来表示学生,类本身是一种类型,Student表示学 ...
- SQLSERVER存储过程的基本语法实例
SQLSERVER存储过程的基本语法实例 SQLSERVER存储过程的基本语法实例 一.定义变量--简单赋值 declare @a intset @a=5 print @a --使用select语句赋 ...
- 2018.11.5 Nescafe26 T1 小猫爬山
题目 题目描述 Freda 和 rainbow 饲养了 N 只小猫,这天,小猫们要去爬山.经历了千辛万苦,小猫们 终于爬上了山顶,但是疲倦的它们再也不想徒步走下山了(呜咕>_<). Fre ...
- (76)zabbix_agentd.conf配置文件详解
############ GENERAL PARAMETERS ################# ### Option: PidFile# Name of PID file.# Agent PID文 ...
- js动态刷新时间
<script type="text/javascript"> //取得系统当前时间 function getTime(){ var myDate = new Date ...
- firewall-cmd 防火墙命令详解 及 TCP Wrappers
firewall-cmd 常用参数及作用 参数 作用 --get-default-zone 查询默认的区域名称 --set-default-zone=<区域名称> 设置默认的区域,使其永久 ...
- BZOJ 4247: 挂饰
背包裸题 #include<cstdio> #include<algorithm> using namespace std; int F[2005]; struct node{ ...
- cacheData
<%@ page language="java" import="java.util.*,com.fiberhome.bcs.appprocess.common.u ...
- package.json文件特殊符号含义
package.json文件里的^和~表示什么意思呢 In the simplest terms, the tilde matches the most recent minor version (t ...