IT/제이쿼리모바일

제이쿼리모바일 tap event

조원태 2017. 2. 3. 23:33
반응형

tap event


version added: 1.0



설명 : 빠르고 완전한 터치 이벤트 후에 트리거됩니다.


jQuery( ".selector" ).on( "tap", function( event ) { ... } )


jQuery Mobile Tap 이벤트는 단일 대상 객체에서 발생하는 빠르고 완전한 터치 이벤트 후에 트리거됩니다. 

터치 제스처의 해제 상태에서 트리거되는 표준 클릭 이벤트와 동일한 제스처입니다.


이 플러그인은 jQuery의 내장 메소드를 확장합니다.


jQuery Mobile이로드되지 않은 경우 메서드가 여전히 존재하므로 .tap () 메서드를 호출하는 것이 직접 실패하지 않을 수 있습니다. 

그러나 예상 된 동작이 발생하지 않습니다.


경고 :주의해서 탭을 사용하십시오.


Tap은 vclick을 사용하므로 터치 장치에서주의해서 사용해야합니다. 

자세한 내용은 vclick API 설명서를 참조하십시오.


예:

탭 이벤트 캡처 및 작동의 간단한 예


<!doctype html>

<html lang="en">

<head>

  <meta charset="utf-8">

  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title>tap demo</title>

  <link rel="stylesheet" href="//code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">

  <script src="//code.jquery.com/jquery-1.10.2.min.js"></script>

  <script src="//code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>

  <style>

  html, body { padding: 0; margin: 0; }

  html, .ui-mobile, .ui-mobile body {

    height: 85px;

  }

  .ui-mobile, .ui-mobile .ui-page {

    min-height: 85px;

  }

  #nav {

    font-size: 200%;

    width:17.1875em;

    margin:17px auto 0 auto;

  }

  #nav a {

    color: #777;

    border: 2px solid #777;

    background-color: #ccc;

    padding: 0.2em 0.6em;

    text-decoration: none;

    float: left;

    margin-right: 0.3em;

  }

  #nav a:hover {

    color: #999;

    border-color: #999;

    background: #eee;

  }

  #nav a.selected,

  #nav a.selected:hover {

    color: #0a0;

    border-color: #0a0;

    background: #afa;

  }

  div.box {

    width: 3em;

    height: 3em;

    background-color: #108040;

  }

  div.box.tap {

    background-color: #7ACEF4;

  }

  </style>

</head>

<body>

 

<h3>Tap the green square to see the above code applied:</h3>

<div class="box"></div>

 

<script>

$(function(){

  $( "div.box" ).bind( "tap", tapHandler );

 

  function tapHandler( event ){

    $( event.target ).addClass( "tap" );

  }

});

</script>

 

</body>

</html>

반응형