2016-08-24 2 views
-2

나는 여기에 새로운 arround 포럼을 좀하려고합니다. 프로그래밍 클래스 (webforce3)를 끝내고 클래스를 검토 할 수있는 모든 것을 테스트했습니다.JQuery : 왜 내 퍼즐이 휴대폰에서 작동하지 않습니까?

첫 번째 질문은 모바일 장치에서 작동하지 않는 것 같은 작은 프로그램/게임에 관한 것입니다. 아무도 나에게 이유에 대한 단서를 줄 수 있습니까?

jquery-ui 또는 내 코드가 잘못 되었나요? 어떤 도움 https://jsfiddle.net/scooterMaya/ujadw43e/2/

감사 :

script> 
    $(function() { 
    $("#sortable").sortable(); 
    $("#sortable").disableSelection(); 
    }); 

    $(document).ready(function(){ 
    $('ul').each(function(){ 
     // get current ul 
     var $ul = $(this); 
     // get array of list items in current ul 
     var $liArr = $ul.children('li'); 
     // sort array of list items in current ul randomly 
     $liArr.sort(function(a,b){ 
     // Get a random number between 0 and 10 
     var temp = parseInt(Math.random()*10); 
     // Get 1 or 0, whether temp is odd or even 
     var isOddOrEven = temp%2; 
     // Get +1 or -1, whether temp greater or smaller than 5 
     var isPosOrNeg = temp>5 ? 1 : -1; 
     // Return -1, 0, or +1 
     return(isOddOrEven*isPosOrNeg); 
     }) 
     // append list items to ul 
     .appendTo($ul);    
    }); 
    }); 
</script> 

최저

은 무슨 일이 일어나고 있는지 확인하기 위해 바이올린을 게시하는 것입니다. 내 온라인 재개 조금 조금만 지정하려고합니다. http://michelcavro.net

+0

터치 모바일에서 작동하지 않습니다입니까? –

+0

에 오신 것을 환영합니다. [here] (http://stackoverflow.com/help/how-to-ask) 읽기를 원할 수도 있습니다. 일반적인 디버깅 도움말을 묻는 질문은 주제와 관련이 없습니다. 더 자세하게 얘기해 주 시겠어요? – Andy

+0

안녕하세요, 포럼을 둘러 보러 단서를 찾았지만 찾아야 할 것이 없습니다. 귀하의 anwser 도움 : "터치"기능에 대해 몰랐습니다. 고마워. – Scootermaya

답변

0

터치 이벤트로 인해 마우스 끌기가 사진을 드래그하지 않는 것처럼 보입니다. 당신은

이러한 기능

function touchHandler(event) { 
    var touch = event.changedTouches[0]; 

    var simulatedEvent = document.createEvent("MouseEvent"); 
     simulatedEvent.initMouseEvent({ 
     touchstart: "mousedown", 
     touchmove: "mousemove", 
     touchend: "mouseup" 
    }[event.type], true, true, window, 1, 
     touch.screenX, touch.screenY, 
     touch.clientX, touch.clientY, false, 
     false, false, false, 0, null); 

    touch.target.dispatchEvent(simulatedEvent); 
    event.preventDefault(); 
} 

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

을 추가하고 준비 기능의 바닥에서 초기화()를 호출 터치로 마우스 이벤트를 시뮬레이션 할 필요가있다!

이 솔루션은 this SO article

에서하고 업데이트 작업 바이올린 here

+0

굉장! 나는 장치에 대해 뭔가를 배웠다. 나는 "터치"기능에 대해 몰랐다. 많이 Thx 마이클 건배 – Scootermaya

관련 문제