jquery-fastclick


Install
bower install jquery-fastclick

Documentation

jQuery-FastClick

μ„€μΉ˜λ°©λ²•

bower install jquery-fastclick

μ‚¬μš©λ°©λ²•

FastClick 이벀트

fastclick μ΄λΌλŠ” 이벀트λͺ…을 μ‚¬μš©ν•˜λŠ” κ²ƒλ§ŒμœΌλ‘œ κ°„λ‹¨ν•˜κ²Œ μ‚¬μš© ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

$('#id').on('fastclick', function(evt) {

});

이벀트 Delegation 에도 ν™œμš© ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

$(document).on('fastclick', 'div', function(evt) {

});

fastclick 이벀트이 preventDefault ν•¨μˆ˜λ₯Ό ν˜ΈμΆœν•˜λ©΄ click μ΄λ²€νŠΈκ°€ μ€‘λ‹¨λ©λ‹ˆλ‹€.

$('a[href]').on('fastclick', function(evt) {
    evt.preventDefault();
});

μ—°μ†μœΌλ‘œ fastclick 을 ν–ˆλŠ”μ§€ μ•Œ 수 μžˆλ„λ‘ 연속 λ°œμƒ 횟수λ₯Ό 얻을 수 μžˆμŠ΅λ‹ˆλ‹€.

$('#id').on('fastclick', function(evt) {
    switch (evt.detail) {
    case 2:
        console.log('double taps');
        break;

    case 3:
        console.log('triple taps');
        break;
    }
});

연속 fastclick 인지 νŒλ‹¨ν•  수 μžˆλŠ” interval λ₯Ό 지정 ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

jQuery.fastClick.consecutiveInterval = 100; // default: 500

TapHold 이벀트

μΆ”κ°€λ‘œ taphold μ΄λ²€νŠΈλ„ μ œκ³΅ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

$('button').on('taphold', function(evt) {

});

TapHold 인지에 μ‚¬μš©λ˜λŠ” duration 을 지정할 수 μžˆμŠ΅λ‹ˆλ‹€.

jQuery.fastClick.tapHoldDuration = 500; // default: 1000

기타 κΈ°λŠ₯λ“€

fastclick κ°€λŠ₯ν•œ μ—˜λ¦¬λ¨ΌνŠΈκ°€ active μƒνƒœκ°€ λ˜μ—ˆμ„λ•Œ νŠΉμ •ν•œ CSS 클래슀λͺ…이 μΆ”κ°€λ˜λ„λ‘ 섀정을 톡해 지정 ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

button { border-style:outset; }
button.actived { border-style:inset; }
jQuery.fastClick.activedClassName = 'actived'; // default: 'actived'
jQuery.fastClick.activableSelector = 'button'; // default: 'button a'

Installation

bower install jquery-fastclick

Usage

FastClick event

You can use fastclick event if you just replace event name with fastclick.

$('#id').on('fastclick', function(evt) {

});

You can also use with event delegation.

$(document).on('fastclick', 'div', function(evt) {

});

If you call preventDefault of fastclick, the click event will be prevented.

$('a[href]').on('fastclick', function(evt) {
    evt.preventDefault();
});

You can get a count of consecutive fast-clicks that happened in a short interval.

$('#id').on('fastclick', function(evt) {
    switch (evt.detail) {
    case 2:
        console.log('double taps');
        break;

    case 3:
        console.log('triple taps');
        break;
    }
});

Change the interval be used to detect whether is consecutive or not.

jQuery.fastClick.config.consecutiveInterval = 100; // default: 500

TapHold event

In addition, jQuery-FastClick implements taphold event.

$('button').on('taphold', function(evt) {

});

Set the duration of tap-hold.

jQuery.fastClick.config.tapHoldDuration = 500; // default: 1000

Other functions

When the fast-clickable elements are actived, the elements can have specific CSS className. And you can configure about that.

button { border-style:outset; }
button.actived { border-style:inset; }
jQuery.fastClick.config.activedClassName = 'actived'; // default: 'actived'
jQuery.fastClick.config.activableSelector = 'button'; // default: 'button a'