Commit fd17ce2d by libai

测试

parent 73faa935
Showing with 141 additions and 134 deletions
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<meta http-equiv="Content-Type" Content="text/html; charset=utf-8;"> <meta charset="UTF-8">
<title>移动端触摸滑动</title> <title>输出</title>
<meta name="author" content="rainna" /> <style>
<meta name="keywords" content="rainna's js lib" /> ul.lanren {
<meta name="description" content="移动端触摸滑动" /> margin: 100px auto;
<meta name="viewport" content="target-densitydpi=320,width=640,user-scalable=no"> }
<style>
*{margin:0;padding:0;} .scale_panel {
li{list-style:none;} color: #999;
position: absolute;
line-height: 18px;
left: 60px;
top: -0px;
}
.scale_panel>span:first-child {
position: absolute;
left: -5rem;
font-size: 2rem;
}
.scale_panel>span:nth-child(2) {
position: absolute;
right: -5rem;
font-size: 2rem;
}
.scale>span {
background-color: red;
width: 3rem;
height: 3rem;
position: absolute;
left: -2px;
top: -15px;
cursor: pointer;
border-radius: 50%;
font-size: 2rem;
}
.scale {
background-repeat: repeat-x;
background-position: 0 100%;
background-image: linear-gradient(to right, #08D7F2 0%, #2BF06A 50%, #2BF06A 50%, #FC6076 100%);
border-left: 1px #83BBD9 solid;
width: 43rem;
height: 1rem;
position: relative;
border-radius: 2rem;
}
.scale>div {
background-repeat: repeat-x;
background-color: red;
/*进度条颜色*/
width: 0px;
position: absolute;
height: 1rem;
width: 0;
left: 0;
bottom: 0;
border-radius: 2rem;
}
.lanren>li {
margin-left: 3.5rem;
position: relative;
list-style: none;
font-size: 3rem;
}
.m-slider{width:600px;margin:50px 20px;overflow:hidden;} #title {
.m-slider .cnt{position:relative;left:0;width:3000px;} position: absolute;
.m-slider .cnt li{float:left;width:600px;} top: -6rem;
.m-slider .cnt img{display:block;width:100%;height:450px;} left: 23rem;
.m-slider .cnt p{margin:20px 0;} }
.m-slider .icons{text-align:center;color:#000;} </style>
.m-slider .icons span{margin:0 5px;}
.m-slider .icons .curr{color:red;}
.f-anim{-webkit-transition:left .2s linear;}
</style>
</head> </head>
<body> <body>
<div class="m-slider"> <!-- 可拖拽进度条 -->
<ul class="cnt" id="slider"> <div class="nimo"><img src="" alt=""></div>
<li> <ul class="lanren">
<img src="http://imglf1.ph.126.net/qKodH3sZoVbPalKFtHS9mw==/6608946691259322175.jpg"> <li><span id="title">0</span>
<p>20140813镜面的世界,终究只是倒影。看得到你的身影,却触摸不到你的未来</p> <div class="scale_panel">
</li> <span class="f-left">开始</span>
<li> <span class="f-right">结束</span>
<img src="http://imglf1.ph.126.net/40-jqH_j6EoCWnZOixY2pA==/4798022453110310215.jpg"> <div class="scale" id="bar">
<p>20140812锡林浩特前往东乌旗S101必经之处,一条极美的铁路。铁路下面是个小型的盐沼,淡淡的有了一丝天空之境的感觉。可惜在此玩了一个小时也没有看见一列火车经过,只好继续赶往东乌旗。</p> <div></div>
</li> <span id="btn"></span>
<li> </div>
<img src="http://imglf0.ph.126.net/Jnmi2y51zVdjKAYlibtpFw==/3068640196117481166.jpg"> </div>
<p>20140811水的颜色为什么那么蓝,我也纳闷,反正自然饱和度和对比度拉完就是这个颜色的</p>
</li>
<li>
<img src="http://imglf1.ph.126.net/79GPsjhwiIj8e-0nP5MsEQ==/6619295294699949331.jpg">
<p>海洋星球3重庆天气热得我想卧轨自杀</p>
</li>
<li>
<img src="http://imglf1.ph.126.net/40-jqH_j6EoCWnZOixY2pA==/4798022453110310215.jpg">
<p>以上这些作品分别来自两位设计师作为观者,您能否通过设计风格进行区分</p>
</li> </li>
</ul> </ul>
<div class="icons" id="icons"> <script src="lib/jquery-3.1.1.min.js"></script>
<span class="curr">1</span> <script>
<span>2</span> $.ajax({
<span>3</span> url:'http://openapi.lvdou66.com/captcha/slide/get.html',
<span>4</span> data:{
<span>5</span> phone:17722581707
</div> },
</div> type:"post",
success:function(msg){
<script> var data = JSON.parse(msg)
var slider = { console.log(data)
//判断设备是否支持touch事件 $(".nimo img").attr("src",""+data.background+"")
touch:('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch,
slider:document.getElementById('slider'),
//事件
events:{
index:0, //显示元素的索引
slider:this.slider, //this为slider对象
icons:document.getElementById('icons'),
icon:this.icons.getElementsByTagName('span'),
handleEvent:function(event){
var self = this; //this指events对象
if(event.type == 'touchstart'){
self.start(event);
}else if(event.type == 'touchmove'){
self.move(event);
}else if(event.type == 'touchend'){
self.end(event);
} }
}, })
//滑动开始 // 进度条代码
start:function(event){ var scale = function (btn, bar, title) {
var touch = event.targetTouches[0]; //touches数组对象获得屏幕上所有的touch,取第一个touch this.btn = document.getElementById(btn);
startPos = {x:touch.pageX,y:touch.pageY,time:+new Date}; //取第一个touch的坐标值 this.bar = document.getElementById(bar);
isScrolling = 0; //这个参数判断是垂直滚动还是水平滚动 this.title = document.getElementById(title);
this.slider.addEventListener('touchmove',this,false); this.step = this.bar.getElementsByTagName("div")[0];
this.slider.addEventListener('touchend',this,false); this.init();
}, };
//移动 scale.prototype = {
move:function(event){ init: function () {
//当屏幕有多个touch或者页面被缩放过,就不执行move操作 var f = this, g = document, b = window, m = Math;
if(event.targetTouches.length > 1 || event.scale && event.scale !== 1) return; f.btn.ontouchstart = function (e) {
var touch = event.targetTouches[0]; var x = (e || b.event).touches[0].clientX;
endPos = {x:touch.pageX - startPos.x,y:touch.pageY - startPos.y}; var l = this.offsetLeft;
isScrolling = Math.abs(endPos.x) < Math.abs(endPos.y) ? 1:0; //isScrolling为1时,表示纵向滑动,0为横向滑动 var max = f.bar.offsetWidth - this.offsetWidth;
if(isScrolling === 0){ g.ontouchmove = function (e) {
event.preventDefault(); //阻止触摸事件的默认行为,即阻止滚屏 var thisX = (e || b.event).touches[0].clientX;
this.slider.className = 'cnt'; var to = m.min(max, m.max(-2, l + (thisX - x)));
this.slider.style.left = -this.index*600 + endPos.x + 'px'; f.btn.style.left = to + 'px';
f.ondrag(m.round(m.max(0, to / max) * 100), to);
b.getSelection ? b.getSelection().removeAllRanges() : g.selection.empty();
};
g.ontouchend = new Function('this.οnmοusemοve=null');
};
},
ondrag: function (pos, x) {
this.step.style.width = Math.max(0, x) + 'px';
this.title.innerHTML = pos + '%';
} }
},
//滑动释放
end:function(event){
var duration = +new Date - startPos.time; //滑动的持续时间
if(isScrolling === 0){ //当为水平滚动时
this.icon[this.index].className = '';
if(Number(duration) > 10){
//判断是左移还是右移,当偏移量大于10时执行
if(endPos.x > 10){
if(this.index !== 0) this.index -= 1;
}else if(endPos.x < -10){
if(this.index !== this.icon.length-1) this.index += 1;
}
}
this.icon[this.index].className = 'curr';
this.slider.className = 'cnt f-anim';
this.slider.style.left = -this.index*600 + 'px';
}
//解绑事件
this.slider.removeEventListener('touchmove',this,false);
this.slider.removeEventListener('touchend',this,false);
} }
}, new scale('btn', 'bar', 'title');
// });
//初始化 </script>
init:function(){
var self = this; //this指slider对象
if(!!self.touch) self.slider.addEventListener('touchstart',self.events,false); //addEventListener第二个参数可以传一个对象,会调用该对象的handleEvent属性
}
};
slider.init();
</script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -32,9 +32,12 @@ ...@@ -32,9 +32,12 @@
<div class="login-btn">登录</div> <div class="login-btn">登录</div>
</div> </div>
</div> </div>
<div class="yanzheng-shadow"></div> <div class="yanzheng-shadow">
<img src="" alt="">
</div>
</body> </body>
<script src="lib/jquery-3.1.1.min.js"></script>w
<script src="lib/jquery-3.1.1.min.js"></script>w
<script src="lib/fingerprint2.js"></script> <script src="lib/fingerprint2.js"></script>
<script src="layer-v3.1.0/layer/layer.js"></script> <script src="layer-v3.1.0/layer/layer.js"></script>
<script> <script>
...@@ -69,16 +72,7 @@ ...@@ -69,16 +72,7 @@
} }
}) })
} }
// $.ajax({
// url:'http://openapi.lvdou66.com/captcha/slide/get.html',
// data:{
// phone:17722581707
// },
// type:"post",
// success:function(data){
// console.log(data)
// }
// })
$(".code-btn").on("click", function () { $(".code-btn").on("click", function () {
if ($(".login-phone-ipt").val().length > 10) { if ($(".login-phone-ipt").val().length > 10) {
$.ajax({ $.ajax({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment