<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>微信滑動(dòng)刪除</title>
<!--<link rel="stylesheet" type="text/css" href="base.css"/>-->
<style>
*{
padding: 0;
margin: 0;
}
html {
font-size: 20px;
}
body {
font-size: 16px;
}
@media only screen and (max-width: 320px) { html {
font-size: 42.7px !important;
}}
@media only screen and (min-width: 321px) and (max-width: 360px) { html {
font-size: 48px !important;
}}
@media only screen and (min-width: 361px) and (max-width: 375px) { html {
font-size: 50px !important;
}}
@media only screen and (min-width: 376px) and (max-width: 384px) { html {
font-size: 52.1px !important;
}}
@media only screen and (min-width: 385px) and (max-width: 414px) { html {
font-size: 55.2px !important;
}}
@media only screen and (min-width: 415px) and (max-width: 480px) { html {
font-size: 64px !important;
}}
@media only screen and (min-width: 481px) and (max-width: 540px) { html {
font-size: 72px !important;
}}
@media only screen and (min-width: 750px) { html {
font-size: 100px !important;
}}
.line{
width: 7.5rem;
height: 1.35rem;
}
.line_move{
width: 7.5rem;
height: 100%;
font-size: 0.28rem;
padding-left: 0.3rem;
padding-right: 0.3rem;
border-bottom: 1px solid #E0E0E0;
background-color: white;
box-sizing: border-box;
float: left;
position: relative;
z-index: 2;
}
.reimbu_top{
padding-top: 0.2rem;
}
.reimbu_top>span:nth-child(2){
float: right;
color: #FFAA00;
}
.reimbu_bottom{
margin-top: 0.2rem;
margin-bottom: 0.2rem;
}
.reimbu_bottom>span:nth-child(2){
float: right;
}
.line_right{
position: relative;
left: 4.3rem;
height: 1.32rem;
width: 3.2rem;
}
.line_right div{
width: 1.6rem;
height: 1.32rem;
line-height: 1.32rem;
text-align: center;
font-size: 0.26rem;
box-sizing: border-box;
}
.line_right>div:nth-child(1){
background-color: yellow;
position: absolute;
top: 0;
right: 1.6rem;
}
.line_right>div:nth-child(2){
background-color: #fb4748;
position: absolute;
top: 0;
right: 0;
}
</style>
</head>
<body>
<div class="box-1">
<div class="box_count">
<div class="line">
<div class="line_move" index="1">
<div class="reimbu_top">
<span>做個(gè)安靜的美女子</span>
<span>10001.00元</span>
</div>
<div class="reimbu_bottom">
<span>2017-08-28</span>
<span>未打印</span>
</div>
</div>
<div class="line_right">
<div>編輯</div>
<div onclick="test(1)">刪除</div>
</div>
</div>
<div class="line">
<div class="line_move" index="1">
<div class="reimbu_top">
<span>做個(gè)安靜的美女子</span>
<span>10001.00元</span>
</div>
<div class="reimbu_bottom">
<span>2017-08-28</span>
<span>未打印</span>
</div>
</div>
<div class="line_right">
<div>編輯</div>
<div onclick="test(1)">刪除</div>
</div>
</div>
<div class="line">
<div class="line_move" index="1">
<div class="reimbu_top">
<span>做個(gè)安靜的美女子</span>
<span>10001.00元</span>
</div>
<div class="reimbu_bottom">
<span>2017-08-28</span>
<span>未打印</span>
</div>
</div>
<div class="line_right">
<div>編輯</div>
<div onclick="test(1)">刪除</div>
</div>
</div>
<div class="line">
<div class="line_move" index="1">
<div class="reimbu_top">
<span>做個(gè)安靜的美女子</span>
<span>10001.00元</span>
</div>
<div class="reimbu_bottom">
<span>2017-08-28</span>
<span>未打印</span>
</div>
</div>
<div class="line_right">
<div>編輯</div>
<div onclick="test(1)">刪除</div>
</div>
</div>
<div class="line">
<div class="line_move" index="1">
<div class="reimbu_top">
<span>做個(gè)安靜的美女子</span>
<span>10001.00元</span>
</div>
<div class="reimbu_bottom">
<span>2017-08-28</span>
<span>未打印</span>
</div>
</div>
<div class="line_right">
<div>編輯</div>
<div onclick="test(1)">刪除</div>
</div>
</div>
<div class="line">
<div class="line_move" index="1">
<div class="reimbu_top">
<span>做個(gè)安靜的美女子</span>
<span>10001.00元</span>
</div>
<div class="reimbu_bottom">
<span>2017-08-28</span>
<span>未打印</span>
</div>
</div>
<div class="line_right">
<div>編輯</div>
<div onclick="test(1)">刪除</div>
</div>
</div>
<div class="line">
<div class="line_move" index="1">
<div class="reimbu_top">
<span>做個(gè)安靜的美女子</span>
<span>10001.00元</span>
</div>
<div class="reimbu_bottom">
<span>2017-08-28</span>
<span>未打印</span>
</div>
</div>
<div class="line_right">
<div>編輯</div>
<div onclick="test(1)">刪除</div>
</div>
</div>
<div class="line">
<div class="line_move" index="1">
<div class="reimbu_top">
<span>做個(gè)安靜的美女子</span>
<span>10001.00元</span>
</div>
<div class="reimbu_bottom">
<span>2017-08-28</span>
<span>未打印</span>
</div>
</div>
<div class="line_right">
<div>編輯</div>
<div onclick="test(1)">刪除</div>
</div>
</div>
<div class="line">
<div class="line_move" index="1">
<div class="reimbu_top">
<span>做個(gè)安靜的美女子</span>
<span>10001.00元</span>
</div>
<div class="reimbu_bottom">
<span>2017-08-28</span>
<span>未打印</span>
</div>
</div>
<div class="line_right">
<div>編輯</div>
<div onclick="test(1)">刪除</div>
</div>
</div>
<div class="line">
<div class="line_move" index="1">
<div class="reimbu_top">
<span>做個(gè)安靜的美女子</span>
<span>10001.00元</span>
</div>
<div class="reimbu_bottom">
<span>2017-08-28</span>
<span>未打印</span>
</div>
</div>
<div class="line_right">
<div>編輯</div>
<div onclick="test(1)">刪除</div>
</div>
</div>
<div class="line">
<div class="line_move" index="1">
<div class="reimbu_top">
<span>做個(gè)安靜的美女子</span>
<span>10001.00元</span>
</div>
<div class="reimbu_bottom">
<span>2017-08-28</span>
<span>未打印</span>
</div>
</div>
<div class="line_right">
<div>編輯</div>
<div onclick="test(1)">刪除</div>
</div>
</div>
<div class="line">
<div class="line_move" index="1">
<div class="reimbu_top">
<span>做個(gè)安靜的美女子</span>
<span>10001.00元</span>
</div>
<div class="reimbu_bottom">
<span>2017-08-28</span>
<span>未打印</span>
</div>
</div>
<div class="line_right">
<div>編輯</div>
<div onclick="test(1)">刪除</div>
</div>
</div>
</div>
</div>
<script>
var moveArr = document.getElementsByClassName('line_move');
var startX = 0;
var moveX = 0;
var moveStatus = 0; // 0:未滑出 1:已滑出
var arr = []; // 判斷手指觸摸數(shù)量
function handler() {
return false;
}
for(var i=0; i<moveArr.length; i++) {
moveArr[i].addEventListener('touchstart', function(event){
startX = event.touches[0].clientX;
arr.push(this.getAttribute('index')); //arr.push(1); 不需要索引值就用這個(gè)
// 添加阻止默認(rèn)行為
// this.addEventListener('touchmove', handler, false);
})
moveArr[i].addEventListener('touchmove', function(event){
moveX = event.touches[0].clientX - startX;
})
moveArr[i].addEventListener('touchend', function(event){
moveEnd = moveX*0.01;
console.log(moveEnd);
//向左滑動(dòng)
if( moveEnd < 0 && moveStatus == 0){ //未滑出
if( Math.abs(moveEnd) > 1 ){
this.style.transform = "translate("+-3.2+"rem)";
moveStatus = 1;
}else{
this.style.transform = "translate("+0+"rem)";
moveStatus = 0;
}
}else if(moveEnd < 0 && moveStatus == 1){ //已滑出
moveArr[this.getAttribute('index')].style.transform = "translate("+0+"rem)";
moveStatus = 0;
// 向右滑動(dòng)
}else if(moveEnd > 0 && moveEnd > 1){
this.style.transform = "translate("+0+"rem)";
moveStatus = 0;
}
this.style.transitionDuration ="0.5s";
moveX = 0;
// 解綁事件
this.removeEventListener('touchmove', handler, false);
})
}
for(var i=0; i<moveArr.length; i++) {
moveArr[i].addEventListener("touchstart", function(e){
arr = [];
moveStatus = 0;
for(var j=0; j<moveArr.length; j++){
moveArr[j].style.transform = "translate("+0+"rem)";
}
});
}
</script>
</body>
</html>
原聲js模擬微信滑動(dòng)
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門盅抚,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人倔矾,你說我怎么就攤上這事妄均。” “怎么了哪自?”我有些...
- 文/不壞的土叔 我叫張陵丰包,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我提陶,道長(zhǎng)烫沙,這世上最難降的妖魔是什么匹层? 我笑而不...
- 正文 為了忘掉前任隙笆,我火速辦了婚禮锌蓄,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘撑柔。我一直安慰自己瘸爽,他們只是感情好,可當(dāng)我...
- 文/花漫 我一把揭開白布铅忿。 她就那樣靜靜地躺著剪决,像睡著了一般。 火紅的嫁衣襯著肌膚如雪檀训。 梳的紋絲不亂的頭發(fā)上柑潦,一...
- 文/蒼蘭香墨 我猛地睜開眼命锄,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼堰乔!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起脐恩,我...
- 序言:老撾萬(wàn)榮一對(duì)情侶失蹤镐侯,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后被盈,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體析孽,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年只怎,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了袜瞬。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
- 正文 年R本政府宣布,位于F島的核電站擅这,受9級(jí)特大地震影響澈魄,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜仲翎,卻給世界環(huán)境...
- 文/蒙蒙 一痹扇、第九天 我趴在偏房一處隱蔽的房頂上張望铛漓。 院中可真熱鬧,春花似錦鲫构、人聲如沸浓恶。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)包晰。三九已至,卻和暖如春炕吸,著一層夾襖步出監(jiān)牢的瞬間伐憾,已是汗流浹背。 一陣腳步聲響...
- 正文 我出身青樓嘴瓤,卻偏偏與公主長(zhǎng)得像扫外,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子廓脆,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- 春節(jié)在家無聊筛谚,搶紅包的時(shí)候想起來,不如自己寫一個(gè)微信搶紅包算法來練練手停忿。本以為是非常簡(jiǎn)單的一個(gè)事情驾讲,但真正寫下來也...
- JavaScript 類型轉(zhuǎn)換Number() 轉(zhuǎn)換為數(shù)字纸肉, String() 轉(zhuǎn)換為字符串, Boolean()...
- 一 自定義WeiXinTabChangeView 1 自定義屬性attrs.xml: <?xml v...
- 她跟閨密聊天喊熟,在感嘆柏肪,今天要下雨了可是家里還曬著被子,沒人給收一下芥牌,早上還是大太陽(yáng)烦味,下午就是陰云密布了, 幾天前壁拉,...
- 楔子 漢武帝讀司馬相如的子虛賦谬俄,忽然悵恨地說: “朕獨(dú)不得與此人同時(shí)哉岩遗!” 他錯(cuò)了,司馬相如并沒有死凤瘦,好文章并不一...