Skip to content

CHICPRO

  • Life Log
  • Cycling Log
  • Photo Log
    • Portrait
    • Landscape
    • Flower
    • Etc
  • Coding Log
  • Information

jQuery touchSwipe 플러그인

2013-10-21 by 편리

모바일 쇼핑몰에서 사용할 swipe 플러그인을 찾아보니 jQuery touchSwipe라는 플러그인을 찾게 됐다. 다른 플러그인들에 비해서 용량은 좀 크지만 터치시 움직일 때마다 실시간으로 움직인 거리 등의 정보를 얻을 수 있는 점이 마음에 들어서 사용해보려 한다. 아직 테스트를 진행하고 있지만 괜찮은 플러그인인 것 같다.

$("#touch").swipe({
    swipe: function(event, direction, distance, duration, fingerCount) {
        switch(direction) {
            case "left":
                alert("left");
                break;
            case "right":
                alert("right");
                break;           
        }        
    }
});

기본적으로 위와같은 방법으로 사용할 수 있다. 이렇게 사용했을 때 기본적으로 #touch 엘리먼트의 자식 엘리먼트 중 input, a 등의 엘리먼트는 이벤트에서 제외되도록 설정되어 있다. 그래서 이벤트가 발생하지 않아 처음에 엄청 당황스러웠는데 excludedElements:”.noSwipe” 와 같이 제외되는 엘리먼트를 재설정 해주면 된다.

$("#touch").swipe({
    swipe: function(event, direction, distance, duration, fingerCount) {
        switch(direction) {
            case "left":
                alert("left");
                break;
            case "right":
                alert("right");
                break;           
        },
        threshold: 0,
        excludedElements:".noSwipe",
        allowPageScroll:"vertical"
    }
});

위 코드는 제외되는 엘리먼트 재설정과 세로 스크롤을 허용하는 부분이 추가되어 있다. 아래 첨부 파일은 1.6.5 버전의 압축 파일이다.

jquery.touchSwipe.zip

Post navigation

Previous Post:

Windows 8.1을 설치해봤다

Next Post:

어찌나 피곤한지..

One comment

  1. H에이치 says:
    2018-06-01 at 13:34

    안녕하세요. 편리님.

    스크립트에 오류가 있어서 글 남깁니다.

    swipe: function(event, direction, distance, duration, fingerCount) {
    switch(direction) {
    case “left”:
    alert(“left”);
    break;
    case “right”:
    alert(“right”);
    break;
    },
    threshold: 0,
    excludedElements:”.noSwipe”,
    allowPageScroll:”vertical”
    }

    — >

    swipe: function(event, direction, distance, duration, fingerCount) {
    switch(direction) {
    case “left”:
    alert(“left”);
    break;
    case “right”:
    alert(“right”);
    break;
    }
    },
    threshold: 0,
    excludedElements:”.noSwipe”,
    allowPageScroll:”vertical”

    이렇게 되어야 할거같습니다.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • SK 세븐모바일 유심 셀프교체
  • php 배열 연산에서 + 와 array_merge 의 차이
  • pcntl_fork 를 이용한 다중 프로세스 실행
  • 아이폰 단축어를 이용하여 주중 공휴일엔 알람 울리지 않게 하기
  • 구글 캘린더 전체일정 재동기화
  • OpenLiteSpeed 웹서버에 HTTP 인증 적용
  • OpenLiteSpeed 웹어드민 도메인 연결
  • WireGuard를 이용한 VPN 환경 구축
  • Ubuntu 22.04 서버에 OpenLiteSpeed 웹서버 세팅
  • 맥 vim 세팅

Recent Comments

  • 편리 on 업무관리용 그누보드 게시판 스킨
  • 임종섭 on 업무관리용 그누보드 게시판 스킨
  • 캐논 5D 펌웨어 | Dslr 펌웨어 업그레이드 방법 82 개의 베스트 답변 on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • Top 5 캐논 5D 펌웨어 Top 89 Best Answers on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • 편리 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 임팀장 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 편리 on Notepad++ NppFTP 플러그인 수동 설치
  • paul-j on Notepad++ NppFTP 플러그인 수동 설치
  • YS on Windows 10 iCloud 사진 저장 폴더 변경
  • 편리 on Docker를 이용한 Centos7 + httpd + php 5.4 개발환경 구축

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
© 2025 CHICPRO | Built using WordPress and SuperbThemes