$(function(){
(function(){ var LSwiperMaker = function(o){ var that = this;
this.config = o;
this.control = false;
this.sPos = {};
this.mPos = {};
this.dire; // this.config.bind.addEventListener('touchstart', function(){ return that.start(); } ,false);
// 这样不对的,event对象只在事件发生的过程中才有效;
this.config.bind.addEventListener('touchstart', function(e){ return that.start(e); } ,false);
this.config.bind.addEventListener('touchmove', function(e){ return that.move(e); } ,false);
this.config.bind.addEventListener('touchend', function(e){ return that.end(e); } ,false); };
LSwiperMaker.prototype.start = function(e){
var point = e.touches ? e.touches[0] : e;
this.sPos.x = point.screenX;
this.sPos.y = point.screenY;
};
LSwiperMaker.prototype.move = function(e){ var point = e.touches ? e.touches[0] : e;
this.control = true;
this.mPos.x = point.screenX;
this.mPos.y = point.screenY; }; LSwiperMaker.prototype.end = function(e){ this.config.dire_h && (!this.control ? this.dire = null : this.mPos.x > this.sPos.x ? this.dire = 'R' : this.dire = 'L');
this.config.dire_h || (!this.control ? this.dire = null : this.mPos.y > this.sPos.y ? this.dire = 'D' : this.dire = 'U'); this.control = false;
this.config.backfn(this); }; window.LSwiperMaker = LSwiperMaker;
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);// 禁止微信touchmove冲突
}());
for(var i= 1;i<7;i++){
function hd(i){
var a = new LSwiperMaker({
bind:document.getElementById("page"+i+""), // 绑定的DOM对象
dire_h:false, //true 判断左右, false 判断上下
backfn:function(o){ //回调事件             //这里写怎样滑动           }
});
}
hd(i);
} });

  

js移动端判断上下左右划屏的更多相关文章

  1. [原创]zepto打造一款移动端划屏插件

    最近忙着将项目内的jquery 2换成zepto 因为不想引用过多的zepto包,所以花了点时间 zepto真的精简了许多,源代码看着真舒服 正好项目内需要一个划屏插件,就用zepto写了一个 逻辑其 ...

  2. js常见的判断移动端或者pc端或者安卓和苹果浏览器的方法总结

    1.js常见的判断移动端或者pc端或者安卓和苹果浏览器的方法总结 : http://www.haorooms.com/post/js_pc_iosandmobile 2.Js判断客户端是否为PC还是手 ...

  3. 基于animate.css动画库的全屏滚动小插件,适用于vue.js(移动端、pc)项目

    功能简介 基于animate.css动画库的全屏滚动,适用于vue.js(移动端.pc)项目. 安装 npm install vue-animate-fullpage --save 使用 main.j ...

  4. HTML5中判断横屏竖屏

    在移动端中我们经常碰到横屏竖屏的问题,那么我们应该如何去判断或者针对横屏.竖屏来写不同的代码呢. 这里有两种方法: 一:CSS判断横屏竖屏 写在同一个CSS中 1 2 3 4 5 6 @media s ...

  5. 有了这套flexible.js 移动端自适应方案,你就能在移动端的来去自如, (*^__^*)

    flexible.js 移动端自适应方案 一,flexible.js 的使用方式: github地址:https://github.com/amfe/lib-flexible 官方文档地址:https ...

  6. 用JavaScript判断横屏竖屏问题。JavaScript代码如下【转】

    /判断手机横竖屏状态: function hengshuping(){ if(window.orientation==180||window.orientation==0){ alert(" ...

  7. 用JavaScript判断横屏竖屏问题

    判断手机横竖屏状态: //判断手机横竖屏状态: function hengshuping() { if(window.orientation == 180 || window.orientation= ...

  8. JavaScript判断横屏/竖屏

    /判断手机横竖屏状态:  function hengshuping(){    if(window.orientation==180||window.orientation==0){          ...

  9. JS前端开发判断是否是手机端并跳转操作(小结)

    JS前端开发判断是否是手机端并跳转操作(小结) 这篇文章主要介绍了JS前端开发判断是否是手机端并跳转操作,非常不错,具有参考借鉴价值,需要的朋友可以参考下 常用跳转代码 ? 1 2 3 4 5 6 7 ...

随机推荐

  1. 2019-8-31-dotnet-特性-DynamicallyInvokable-是用来做什么的

    title author date CreateTime categories dotnet 特性 DynamicallyInvokable 是用来做什么的 lindexi 2019-08-31 16 ...

  2. 第三方下载控件 用起来还是不错的偶!Aria

    本文主要介绍开源项目Aria的使用. 先在项目里的build 中配置compile 'com.arialyy.aria:Aria:3.1.1' //下载 开始下载 Aria.download(this ...

  3. RSA算法的基本原理

    记得在我上初一的时候做过这么一道数学竞赛题,就是求7的222次方的个位数字.当时教材上介绍的解题方法是将222分解成4*55+2,然后算出7的2次方个个位数字即为要算的数值.当时年幼无知的我根本不了解 ...

  4. 「题解」NOIP模拟测试题解乱写II(36)

    毕竟考得太频繁了于是不可能每次考试都写题解.(我解释个什么劲啊又没有人看) 甚至有的题目都没有改掉.跑过来写题解一方面是总结,另一方面也是放松了. NOIP模拟测试36 T1字符 这题我完全懵逼了.就 ...

  5. 字符串+dp——cf1163D好题

    很好的题(又复习了一波kmp) /* dp[i,j,k]:到s1的第i位,匹配s2到j,s3到k的最优解 */ #include<bits/stdc++.h> using namespac ...

  6. opencv-图像类型、深度、通道

    转自:图像类型   与  opencv中图像基础(大小,深度,通道) 一.图像基本类型 在计算机中,按照颜色和灰度的多少可以将图像分为四种基本类型. 1. 二值图像 2. 灰度图像 3. 索引图像 4 ...

  7. Java-JPA:JPA

    ylbtech-Java-JPA:JPA JPA是Java Persistence API的简称,中文名Java持久层API,是JDK 5.0注解或XML描述对象-关系表的映射关系,并将运行期的实体对 ...

  8. bean的使用

    前言 Spring最基础的功能就是一个bean工厂,所以本文讲解的是Spring生成bean的种种方法及细节,Spring配置文件的名字是bean.xml,定义几个类: 一个Person类: publ ...

  9. PAT甲级——A1103 Integer Factorization

    The K−P factorization of a positive integer N is to write N as the sum of the P-th power of Kpositiv ...

  10. QC的安装和配置

    QC(Quality center)的安装配置 Wmware 虚拟机 数据库SQL server2000 Windows server 2003 须安装数据库的sp4补丁包 注意事项 数据库安装时选择 ...