본문 바로가기

IT/JQUERY

jquery swipe 예제

tap
-터치 기반 모바일 기기에서 가장 흔하게 발생하는 이벤트
-데스크탑 환경의 클릭(click)과 유사

taphold
-길게 손가락으로 누르고 있으면 발생하는 이벤트

swipe
-화면을 손가락으로 밀면 발생
-보통 화면을 좌우로 전환 할시 사용함

swipeleft
-왼쪽으로 swipe

swiperight
-오른쪽으로 swipe



<예제>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
    
    <!-- 화면 인코딩 설정 -->
        <meta charset="EUC-KR"/>
        
        <!-- 화면비율(뷰포트) 설정 -->
        <meta name="viewport"
        content="width=device-width,
            initial-scale=1.0,
            maximum-scale=1.0, minimum-scale=1.0,
            user-scalable=no"/>
            
    <!-- 바로가기 아이콘 설정 안드로이드, IOS -->
    <link rel="shortcut icon" href=""/>
    <link rel="apple-touch-icon" href=""/>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    
    
    <script>
    <!-- 이벤트 처리 -->
        $(function(){
            $("#orangeDiv").bind("swipeleft", function(){
                $.mobile.changePage("#bluePage");
            });
            $("#orangeDiv").bind("swiperight", function( ){
                $.mobile.changePage("#greenPage");
            });
            
            $("#blueDiv").bind("swipeleft", function(){
                $.mobile.changePage("#greenPage");
            });
            $("#blueDiv").bind("swiperight", function(){
                $.mobile.changePage("#orangePage");
            });
 
            $("#greenDiv").bind("swipeleft", function(){
                $.mobile.changePage("#orangePage");
            });
            $("#greenDiv").bind("swiperight", function(){
                $.mobile.changePage("#bluePage");
            });
        });
        
        
    </script>
    
<title>Insert title here</title>
</head>
<body>
    <div id="orangePage" data-role="page">
        <div data-role="header">
            <h1>오렌지 페이지</h1>
        </div>
        <div id="orangeDiv" data-role="content"
            style="background-color:orange; height:500px">
        </div>
    </div>
    
    <div id="bluePage" data-role="page">
        <div data-role="header">
            <h1>블루 페이지</h1>
        </div>
        <div id="blueDiv" data-role="content"
            style="background-color:blue; height:500px">
        </div>
    </div>
    
    <div id="greenPage" data-role="page">
        <div data-role="header">
            <h1>그린 페이지</h1>
        </div>
        <div id="greenDiv" data-role="content"
            style="background-color:green; height:500px">
        </div>
    </div>
</body>
</html>