h5 라운드맵

2048 단어










h5  





(function(win,doc){

function change(){

doc.documentElement.style.fontSize=doc.documentElement.clientWidth*20/320+'px';

}

change();

win.addEventListener('resize',change,false);

})(window,document);

window.addEventListener('DOMContentLoaded',function(){

var oUl=document.getElementById('ul1');

var aLi=oUl.getElementsByTagName('li');

var x=0;

var iNow=0;

oUl.addEventListener('touchstart',function(ev){

oUl.style.transition='none';

var disX=ev.targetTouches[0].pageX-x;

var downX=ev.targetTouches[0].pageX;

function fnMove(ev){

x=ev.targetTouches[0].pageX-disX;

oUl.style.transform='translateX('+x+'px)';

}

function fnEnd(ev){

var upX=ev.changedTouches[0].pageX;

if(Math.abs(upX - downX)>50){

if(upX -downX<0){

iNow++;

if(iNow==aLi.length){iNow=aLi.length-1}

}else{

iNow--;

if(iNow==-1){

iNow=0;

}

}

}

x=-iNow*aLi[0].offsetWidth;

oUl.style.transform='translateX('+x+'px)';

oUl.style.transition='200ms all ease';

document.removeEventListener('touchmove',fnMove,false);

document.removeEventListener('touchend',fnEnd,false);

}

document.addEventListener('touchmove',fnMove,false);

document.addEventListener('touchend',fnEnd,false);

ev.preventDefault();

},false);

},false);







  • 1
  • 2
  • 3
  • 4

좋은 웹페이지 즐겨찾기