tounthcyc.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * tounthcyc.js
  3. * 2015-05-01
  4. * */
  5. function load (){
  6. $(document.body).on('touchstart touchmove touchend','.inp', function(e){
  7. touch();
  8. });
  9. // $(".inp").each(function(i, element) {
  10. // $(".inp:eq("+i+")")[0].addEventListener('touchstart',touch, false);
  11. // $(".inp:eq("+i+")")[0].addEventListener('touchmove',touch, false);
  12. // $(".inp:eq("+i+")")[0].addEventListener('touchend',touch, false);
  13. // });
  14. var HandStartX,HandStartY,HandEndX,HandEndY,CountX,CountY;
  15. function touch (event){
  16. //debugger
  17. var event = event || window.event;
  18. var oInp = document.getElementById("inp");
  19. switch(event.type){
  20. case "touchstart"://开始
  21. HandStartX=event.touches[0].clientX;
  22. HandStartY=event.touches[0].clientY;
  23. break;
  24. case "touchend":
  25. HandEndX=event.changedTouches[0].clientX;
  26. HandEndY=event.changedTouches[0].clientY;
  27. CountX=HandEndX-HandStartX;
  28. CountY=HandEndY-HandStartY;
  29. $.CycTounch(event,CountX,CountY)
  30. break;
  31. case "touchmove":
  32. event.preventDefault();
  33. break;
  34. }
  35. }
  36. }