2012-04-26 5 views
0

jQuery UI 슬라이더 & ipad/iphone에서 html 웹 페이지에있는 드래그 % 드롭 것들을 반응 형으로 만들기 위해 이와 같은 코드를 사용하고 있습니다.touch.js iphone에서 jQuery 드래그를 시뮬레이트합니다.

function touchHandler(event) 
{ 
    var touches = event.changedTouches, 
     first = touches[0], 
     type = ""; 

    switch(event.type) 
    { 
     case "touchstart": type = "mousedown"; break; 
     case "touchmove": type="mousemove"; break;   
     case "touchend": type="mouseup"; break; 
     default: return; 
    } 
    var simulatedEvent = document.createEvent("MouseEvent"); 
    simulatedEvent.initMouseEvent(type, true, true, window, 1, 
           first.screenX, first.screenY, 
           first.clientX, first.clientY, false, 
           false, false, false, 0/*left*/, null); 

    first.target.dispatchEvent(simulatedEvent); 

    event.preventDefault(); 
} 

function initTouch() 
{ 
    document.addEventListener("touchstart", touchHandler, true); 
    document.addEventListener("touchmove", touchHandler, true); 
    document.addEventListener("touchend", touchHandler, true); 
    document.addEventListener("touchcancel", touchHandler, true);  
} 
$(document).ready(function(){initTouch();}); 

드래그 앤 슬라이딩이 잘 작동합니다. 문제는 html 버튼 (예 : "입력"또는 "a")에서 간단한 클릭 (탭)을하고 싶지 않은 경우입니다.

"이 터치는 처음 터치하는 것처럼 잘 이해합니다"라고 생각합니다. 어떻게 할 수 있습니까? 움직이거나 끌지 않고 같은 장소에서 간단한 도청을하면 너무 효과가 있습니다. HTML의 특정 요소를 만지는 경우

정말 감사합니다, 리오넬

+0

http://touchpunch.furf.com/ – Lionel

답변

2

는 또한 같은 문제에 직면했다. 그러나 touch.js 파일을 다음과 같이 약간 변경하여이 문제를 해결할 수 있습니다. "if ($ (this) .attr ('href') == ')"before event.preventDefault();

관련 문제