2016-06-27 1 views
0

mousedown 및 mouseup 이벤트를 사용하여 긴 클릭을 식별했습니다. 하지만 그것은 나를 위해 Tizen 에뮬레이터에서 작동하지 않습니다. 그러나 동일한 코드가 브라우저에서 제대로 작동합니다. tizen이 제공하는 타우는 스 와이프 만 지원합니다.웨어링 가능한 앱에서 긴 프레스가 지원 되나요?

아래 코드는 브라우저에서 잘 작동 :

var timeOut; 
 
$("button").mouseup(function(event){ 
 
\t 
 
    clearTimeout(timeOut); 
 
}); 
 
$("button").mousedown(function(event){ 
 
    
 
    timeOut = setTimeout(function(){ 
 
     
 
    \t alert('you hold your mouse more than 2 seconds.!'); 
 
     
 
    },2000); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<button>click me</button>

Referred this fiddle too

그러나 아무것도 타 이젠 착용 할 수있는 에뮬레이터에서 작동하지 않습니다. 그래서 내가 시도 할 수있는 다른 제안?

답변

2

'mousedown'및 'mouseup'대신 'touchstart'및 'touchend'를 사용할 수 있습니다.

기본 웹 템플릿으로 아래 코드를 테스트했습니다. 잘 작동합니다! :)

main.js

window.onload = function() { 
// TODO:: Do your initialization job 

// add eventListener for tizenhwkey 
document.addEventListener('tizenhwkey', function(e) { 
    if (e.keyName === "back") { 
     try { 
      tizen.application.getCurrentApplication().exit(); 
     } catch (ignore) {} 
    } 
}); 

// Sample code 
var mainPage = document.querySelector('#main'); 

var timeOut; 
var cnt = 0; 
mainPage.addEventListener("touchend", function() { 
    var contentText = document.querySelector('#content-text'); 
    console.log("timer clear!"); 
    clearTimeout(timeOut); 
}); 

mainPage.addEventListener("touchstart", function() { 
    var contentText = document.querySelector('#content-text'); 
    console.log("touchstart!"); 
    timeOut = setTimeout(function(){ 
     console.log("long!"); 
     contentText.innerHTML = "Long!" + cnt; 
     cnt++; 
    },2000); 
}); 

};

+0

괜찮 았는데 .... 고마워! – Priya

관련 문제