반응형
블로그 이미지
개발자로서 현장에서 일하면서 새로 접하는 기술들이나 알게된 정보 등을 정리하기 위한 블로그입니다. 운 좋게 미국에서 큰 회사들의 프로젝트에서 컬설턴트로 일하고 있어서 새로운 기술들을 접할 기회가 많이 있습니다. 미국의 IT 프로젝트에서 사용되는 툴들에 대해 많은 분들과 정보를 공유하고 싶습니다.
솔웅

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

카테고리

Virtual Events 알아보기

2012. 9. 30. 22:54 | Posted by 솔웅


반응형

Virtual Events


virtual event들을 사용하는 이유는 HTML element를 trigger 할 수 있는 손가락이나 mouse 와 관련된 이벤트들을 표준화 하기 위해서 입니다. 이러한 이벤트들은 서로 다른 이름들을 가지고 있습니다. (eg touchstart and click for click type events, or touchmove and mousemove to move type events) jQuery Mobile 은 virtual events라고  하는 것을 만들어서 이러한 이벤트들의 이름을 표준화 했습니다.


Virtual events

Name

Signification

vclick

Idem click. Warning: jQuery Mobile developers recommend not to use the vclick event when it produces a change in the display (eg click on a link that shows a new window), because the vclick event is sometimes triggered two times - instead of one - when set on a particular element. In these cases, they recommend using click instead. Apart from these elements that can cause problems, we will use vclick.

vmousemove

Idem mousemove.

vmouseover

Idem mouseover.

vmousedown

Idem mousedown.

vmouseup

Idem mouseup.

vmouseout

Idem mouseout.

vmousecancel

Idem mousecancel.


아래 예제는 윈도우에서 어떤 이벤트가 발생 했을 때 그 이벤트의 이름을 화면에 보여 줍니다.


Detect and display the virtual events


<!DOCTYPE html>

<html> 

<head> 

  <meta name=viewport content="user-scalable=no,width=device-width" />

  <link rel=stylesheet href=jquery.mobile/jquery.mobile.css />

  <script src=jquery.js></script>

  <script src=jquery.mobile/jquery.mobile.js></script>

</head> 


<body> 


<div id=home data-role=page id=home>

  <div data-role=header>

    <h1>Home</h1>

  </div>


  <div data-role=content>

    <p> Events </p>

  </div>

</div>


</body>

</html>


<script>


var $content = $("#home div:jqmData(role=content)");


$("#home").bind ("vmouseover", function (event)

{

  $content.append (event.type + ", ");

});


$("#home").bind ("vmousedown", function (event)

{

  $content.append (event.type + ", ");

});


$("#home").bind ("vmousemove", function (event)

{

  $content.append (event.type + ", ");

});


$("#home").bind ("vmouseup", function (event)

{

  $content.append (event.type + ", ");

});


$("#home").bind ("vclick", function (event)

{

  $content.append (event.type + ", ");

});


$("#home").bind ("vmouseout", function (event)

{

  $content.append (event.type + ", ");

});


$("#home").bind ("vmousecancel", function (event)

{

  $content.append (event.type + ", ");

});


</script>







convention04.html



반응형