티스토리 뷰

728x90
var EVENT_DOUBLE_CLICK_DELAY = 200; // Adjust max delay btw two clicks (ms)
var eventClickPending = 0;

document.getElementById('btn').addEventListener('click', function(e){
    if ((e.detail === 2 ) && (eventClickPending!== 0)) {
//       console.log('double click action here ' + e.detail);
         clearTimeout(eventClickPending);
         eventClickPending = 0;
         // call your double click method
         console.log("더블클릭");

    } else if ((e.detail === 1 ) && (eventClickPending=== 0)){   
//      console.log('sigle click action here 1');
        eventClickPending= setTimeout(function() {
//          console.log('Executing sigle click');
            eventClickPending = 0
            // call your single click method
            console.log('one click');
        }, EVENT_DOUBLE_CLICK_DELAY);

//    } else { // do nothing
//      console.log('more than two clicks action here ' + e.detail);
            
    }
});
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/11   »
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
글 보관함