请用chrome手机模式查看或者在手机上查看(转载请注明出处)

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Touch滑动</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="author" contect="Wt, wt9213@163.com" />
<style type="text/css">
body{
margin: 0;
padding: 0;
background-color:#e3e3e3;
}
.list{
margin: 0 auto;
max-width: 720px;
}
.item{
position: relative;
height: 50px;
border-bottom:1px solid #e3e3e3;
}
.touchitem{
position: absolute;
width: 100%;
height: 100%;
line-height: 50px;
font-size: 18px;
z-index: 99;
background-color: #fff;
}
.touchitem span{
padding-left: 20px;
}
.delete{
position: absolute;
top: 0;
right: 0;
height: 100%;
width: 20%;
line-height: 50px;
text-align: center;
background-color:#DE2222;
color: #fff;
z-index: 0;
}
</style>
<script type="text/javascript" src="http://apps.bdimg.com/libs/zepto/1.1.4/zepto.min.js"></script> <!-- 手机端使用zepto.js -->
</head>
<body>
<div class="list">
<div class="item">
<div class="touchitem"><span>滑动删除</span></div>
<div class="delete">删除</div>
</div>
<div class="item">
<div class="touchitem"><span>滑动删除</span></div>
<div class="delete">删除</div>
</div>
<div class="item">
<div class="touchitem"><span>滑动删除</span></div>
<div class="delete">删除</div>
</div>
</div>
<script>
$(function() {
$(".touchitem").on('touchstart', function(e) {
var touch = e.targetTouches[0];
sessionStorage.setItem("touchstartX", touch.pageX); //存储touch到的起始x坐标
});
$(".touchitem").on('touchmove', function(e) {
var touch = e.targetTouches[0];
var x = touch.pageX;
//move的坐标的起始的坐标判断,得出方向
if (x + 15 < sessionStorage.touchstartX) { //左
$(this).css({
"transform": "translate(-20%)"
}); } else if (x - 15 > sessionStorage.touchstartX) { //右
$(this).css({
"transform": "translate(0)"
});
}
});
});
</script>
</body>
</html>

touch实现滑动删除的更多相关文章

  1. RecyclerView拖拽排序和滑动删除实现

    效果图 如何实现 那么是如何实现的呢?主要就要使用到ItemTouchHelper ,ItemTouchHelper 一个帮助开发人员处理拖拽和滑动删除的实现类,它能够让你非常容易实现侧滑删除.拖拽的 ...

  2. ListView滑动删除效果实现

    通过继承ListView然后结合PopupWindow实现 首先是布局文件: delete_btn.xml:这里只需要一个Button <?xml version="1.0" ...

  3. 下拉刷新列表添加SwipeDismissListViewTouchListener实现滑动删除某一列。

    <Android SwipeToDismiss:左右滑动删除ListView条目Item> Android的SwipeToDismiss是github上一个第三方开源框架(github上的 ...

  4. android中列表的滑动删除仿ios滑动删除

    大家是不是觉得ios列表的滑动删除效果很酷炫?不用羡慕android也可以实现相同的效果 并且可以自定义效果,比如左滑删除,置顶,收藏,分享等等 其实就是自定义listview重写listview方法 ...

  5. Android滑动删除功能

    今天学习了新的功能那就是滑动删除数据.先看一下效果 我想这个效果大家都很熟悉吧.是不是在qq上看见过这个效果.俗话说好记性不如赖笔头,为了我的以后,为了跟我一样自学的小伙伴们,我把我的代码粘贴在下面. ...

  6. framework7滑动删除列表触发chrome 报错解决办法

    使用 <div class="list-block"> <ul> <li class="swipeout"> <div ...

  7. android 继承ListView实现滑动删除功能.

    在一些用户体验较好的应用上,可以经常遇见   在ListView中  向左或向右滑动便可删除那一项列表. 具体实现  则是继承ListView实现特定功能即可. (1). 新建 delete_butt ...

  8. 原生H5页面模拟APP左侧滑动删除效果

    话不多说,往左侧滑动,显示删除,我们先来看一下效果图:如下: 这个布局我就不多说,反正就是一行ul,li, class名“item” js代码如下: $(".item").on(& ...

  9. Android开发学习之路-RecyclerView滑动删除和拖动排序

    Android开发学习之路-RecyclerView使用初探 Android开发学习之路-RecyclerView的Item自定义动画及DefaultItemAnimator源码分析 Android开 ...

随机推荐

  1. UITableViewCell -- 动画

    -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath: ...

  2. webpack入门(六)——html-webpack-plugin

    html-webpack-plugin 该插件可以简化创建调用webpack bundles的html文件.在每次编译后,文件名会包含有hash值的bundles 特别有用.你可以让插件为您生成一个H ...

  3. Sublime Text 2搭建Go开发环境

    Sublime Text 2搭建Go开发环境,代码提示+补全+调试 cceevv · 2014-10-11 00:00:06 · 10496 次点击 · 预计阅读时间 3 分钟 · 5分钟之前 开始浏 ...

  4. VM不能ping通www.baidu.com的问题【NAT】 更新了【桥接模式】

    NAT模式 1.为NAT设置子网及掩码等信息 点击VMWare菜单栏“编辑” —> 虚拟网络编辑器 [下图第一张图]—> 选中VMnet8(当然这个看自己的设备后缀是多少了,只要外部连接方 ...

  5. POJ 3469(Dual Core CPU-最小割)[Template:网络流dinic V2]

    Language: Default Dual Core CPU Time Limit: 15000MS   Memory Limit: 131072K Total Submissions: 19321 ...

  6. vs2015终于配置完成了

    安装vs2015,本来应该直接安装vs2015withupdate3的,但是由于当时手上只有vs2015的包,于是直接安装了. 打开C++工程cntk的时候提示需要安装很多东西包括vc编译工具.pyt ...

  7. iOS之简单瀑布流的实现

    iOS之简单瀑布流的实现   前言 超简单的瀑布流实现,这里说一下笔者的思路,详细代码在这里. 实现思路 collectionView能实现各中吊炸天的布局,其精髓就在于UICollectionVie ...

  8. 40个国人iOS技术博客

    40个国人iOS技术博客 博客地址 RSS地址 OneV's Den http://onevcat.com/atom.xml 破船之家 http://beyondvincent.com/atom.xm ...

  9. 零基础学python-4.5 标准类型分类

    1.按存储分:原子类型和容器类型 原子类型:仅仅能包括一个对象 容器类型:能够包括多个对象 分类 python类型 原子类型 数值和字符串 容器类型 列表.元组和字典 2.按能否够变化分:可变和不可变 ...

  10. openwrt 修改 banner

    http://www.network-science.de/ascii/ rectangles 风格