2017-03-06 12 views
2

나는 많은 포럼과 질문을 검색하고 있지만 아무도 각도/이온 2를 두 번 클릭하면 이중 클릭하는 법을 묻지 않는 것 같습니다. 이 on-double-tap 사용할 수 있었다 V1 이온 성에서 더블 탭/더블 클릭 Angular2 & ionic

( http://ionicframework.com/docs/api/directive/onDoubleTap/ 참조)

사람이 어쩌면 이온 2/각 2를 두 번 클릭 이벤트를 잡을 수있는 팁 또는 코드가 있습니까?

어쩌면 HammerJS를 통해?

대단히 감사합니다! 루이스 :

+0

하지 ..하지만 난 당신이 고려해야 수 있다고 생각 [프레스 이벤트 (http://ionicframework.com/docs/v2/components/# 제스처) –

+0

비교적 쉽게 발견했습니다. (dblclick) = https://en.wikipedia.org/wiki/DOM_events#Events의 "myFunction()" – luiswill

+0

ok .. 정말 어떻게 될지 모르겠습니다. 휴대 기기에서 유용 할 수 있습니다. –

답변

4

그래서, 당신은 이온과 더블 클릭 이벤트를 잡을 분명하지 않아도되었다 1-2시간 후하지만 순수한 자바 스크립트로 : 그래서 각도 2 dblclick()

이 될 것이다 : (dblclick)="myFunction()" 그게 다야!

여기에서 JavaScript에 대한 다른 이벤트를 찾을 수 있습니다.

+1

이것은 모바일에서 작동하지 않는 것 같습니다 (iOS에서 테스트 됨) – shakirthow

+0

모바일 iOS에서 작동하지 않습니다. –

0

이온 2에는 HTML에서 액세스 할 수있는 기본 제스처가 있습니다. iOS 및 Android에서 작동해야합니다. documentation here을 찾을 수 있습니다.

그들에 의해 제공되는 소스 코드 is here.

0

간단한 클릭과 더블 클릭에 동일한 버튼을 사용하려면 setTimeout 함수가 도움이 될 수 있습니다. 화살표 구현 =>과 함께 사용해야합니다.

html template

<button (click)="simpleClickFunction()" (dblclick)="doubleClickFunction()">click me!</button> 

Component

simpleClickFunction(): void{ 
    this.timer = 0; 
    this.preventSimpleClick = false; 
    let delay = 200; 

    this.timer = setTimeout(() => { 
     if(!this.preventSimpleClick){ 
     //whatever you want with simple click go here 
     console.log("simple click"); 
     } 
    }, delay); 

    } 

    doubleClickFunction(): void{ 
    this.preventSimpleClick = true; 
    clearTimeout(this.timer); 
    //whatever you want with double click go here 
    console.log("double click"); 
    } 
더블 클릭의 확인