Based on the Zepto phone focus map, view address: Demo (recommended to use mobile browser view) code is as follows:
<! DOCTYPE html>
<title>zepto Achieve the mobile site focus Map touch screen scrub effect </title>
<meta content= "Width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" name= "viewport"/>
<script src= "" type= "Text/javascript" charset= "Utf-8" ></script>
<style>
*{margin:0; padding:0;}
. focus{width:300px; Overflow:hidden;}
. focus. Con{width:1500px;overflow:hidden;}
. focus. con li{font-style:normal;width:300px;height:200px;background: #ccc; text-align:center;float:left;}
. focus. Tit Li{width:20%;float:left;}
. focus. Tit li.on{background: #ccc;}
</style>
<body>
<div class= "Focus" >
<ul class= "Con" >
<li>1111</li>
<li>2222</li>
<li>3333</li>
<li>4444</li>
<li>5555</li>
</ul>
<ul class= >
<li class= "on" >1111</li>
<li>2222</li>
<li>3333</li>
<li>4444</li>
<li>5555</li>
</ul>
</div>
<script>
var touch={};
touch.current=0;
touch.lenght=4;
var touchelem=$ (". Focus ul") [0];
function Move (elem,targetw,current) {
Elem.animate ({
TRANSLATE3D:TARGETW *current + "px,0,0"
},300, ' Steps ', function () {
});
}
function Moveli (current) {
Alert (elem.find ("Li"));
$ (". Tit > Li"). each (function () {
$ (this). Removeclass ("on");
})
$ (". Tit > Li"). EQ (current), AddClass ("on");
}
$ (Touchelem). Unbind (). Bind ("Touchstart", function (e) {
touch.x1 = E.touches[0].pagex;
}). bind ("Touchmove", function (e) {
touch.x2 = E.touches[0].pagex;
touch.x3 = touch.endx+ (touch.x2-touch.x1);
document.title=touch.x2-touch.x1;
$ (this). CSS ("-webkit-transform", "Translate3d (" +touch.x3+ "px, 0px, 0px)");
E.preventdefault ();
}). bind ("Touchend", function (e) {
if (Math.Abs (touch.x2-touch.x1) >=30) {
touch.i = touch.x2-touch.x1 > 0? -1:1;
TOUCH.CURRENT=TOUCH.CURRENT+TOUCH.I;
if (touch.current==-1) {touch.current=0}else if (touch.current>=touch.lenght) {touch.current=touch.lenght;}
}
Document.title=touch.current;
touch.endx=touch.current*-300;
Move ($ (this), -300,touch.current);
Moveli (touch.current);
}). bind (' Touchcancel ', function () {
})
</script>
</body>
Zepto-based mobile phone focus map Touchstart Touchmove