# Unable to use all swipe/darg events, but on-swipe works

**URL:** <https://forum.ionicframework.com/t/unable-to-use-all-swipe-darg-events-but-on-swipe-works/119393>\
**Category:** ionic-v3\
**Created:** [January 25, 2018, 10:59am UTC](https://forum.ionicframework.com/t/unable-to-use-all-swipe-darg-events-but-on-swipe-works/119393 "2018-01-25T10:59:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![800110](https://avatars.discourse-cdn.com/v4/letter/8/a88e57/32.png) [@800110](https://forum.ionicframework.com/u/800110)\
**Post date:** [January 25, 2018, 10:59am UTC](https://forum.ionicframework.com/t/unable-to-use-all-swipe-darg-events-but-on-swipe-works/119393/1 "2018-01-25T10:59:46Z")

</div>

Swipe
 works well. but 
SwipeLeft
 not working, neither the other directions (up,down and right) also the same as other gesture events, on-drag, on-hold,etc....why only on-swipe works. really confuse, anyone can help, thanks ? Ionic version 3.7.0

---

<div class="post-metadata">

**Author:** ![cherry](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/cherry/32/149370_2.png) [@cherry](https://forum.ionicframework.com/u/cherry)\
**Post date:** [January 26, 2018, 12:05am UTC](https://forum.ionicframework.com/t/unable-to-use-all-swipe-darg-events-but-on-swipe-works/119393/2 "2018-01-26T00:05:00Z")

</div>

Can you show me your **HTML** and **TypeScript** code for the **swipe code**.  
Then I might be able to help you. 🙂

---

<div class="post-metadata">

**Author:** ![800110](https://avatars.discourse-cdn.com/v4/letter/8/a88e57/32.png) [@800110](https://forum.ionicframework.com/u/800110)\
**Post date:** [January 26, 2018, 1:27am UTC](https://forum.ionicframework.com/t/unable-to-use-all-swipe-darg-events-but-on-swipe-works/119393/3 "2018-01-26T01:27:40Z")

</div>

Hi cherry,  
very simple demo only the first one works, here is the html and TS code, thank you~

html:

```auto
<div class="divtest" on-swipe="onSwipe()">
    OnSwipe
  </div>

  <div class="divtest" on-swipe-left="onSwipe()">
    OnSwipeLeft~
  </div>

  <div class="divtest" on-swipe-right="onSwipe()">
    OnSwipeRight~
  </div>
  <div class="divtest" on-swipe-up="onSwipe()">
    OnSwipeUp~
  </div>

  <div class="divtest" on-hold="onHold()">
    OnHold
  </div>
  <div class="divtest" (on-drag)="onHold()">
      (on-drag)
    </div>
    <div class="divtest" on-drag="onHold()">
        on-drag
      </div>

  <div class="divtest" (on-hold)="onHold()">
    (OnHold)
  </div>

```

Typescript:

export class HomePage {

constructor(public navCtrl: NavController) {

}

onSwipe(){  
alert(“OnSwipe~”);  
}  
onHold(){  
alert(“OnHold~”);  
}  
}

---

<div class="post-metadata">

**Author:** ![cherry](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/cherry/32/149370_2.png) [@cherry](https://forum.ionicframework.com/u/cherry)\
**Post date:** [January 26, 2018, 2:42am UTC](https://forum.ionicframework.com/t/unable-to-use-all-swipe-darg-events-but-on-swipe-works/119393/4 "2018-01-26T02:42:24Z")

</div>

Here is what you should add to your **TS**.

```auto
import { Component } from '@angular/core';

export class HomePage {
public swipe: number = 0;
}

  constructor() {}

  swipeEvent($e) {
    this.swipe++
    console.log(this.swipe++);
}

```

**HTML**

```auto

<ion-content>
<div class="divtest" (swipe)="swipeEvent($event)">
    OnSwipe
  </div>
</ion-content>

```

So what this basicly does, it recognizes your swipe event with a number wich will be displayed in the console. Now what we want is to recognize if its swiped left/right/up/down.

* * *

**TS**  
_[Ill chose a random number you have to decide wich one is right for you]_

```auto
swipeEvent($e) {
  if ($e.deltaX <= -130) {
      console.log('swiped left');
      }else if{
     ($e.deltaX <= 130)
     console.log('swiped right');
     }else if{
    ($e.deltaY <= 130)
     console.log('swiped up');
     }else if{
    ($e.deltaY <= -130)
    console.log('swiped down');
   }
}

```

Short explanation to the code show above. If the certain number is reached it will print the **console.log** for the reached swiped number. You will have to let go to reset the number.

I hope this gave you an idea how you can play around with swipe gestures. Just try it out and don’t hesitate reporting your results! 🐦

---

<div class="post-metadata">

**Author:** ![800110](https://avatars.discourse-cdn.com/v4/letter/8/a88e57/32.png) [@800110](https://forum.ionicframework.com/u/800110)\
**Post date:** [January 26, 2018, 8:58am UTC](https://forum.ionicframework.com/t/unable-to-use-all-swipe-darg-events-but-on-swipe-works/119393/5 "2018-01-26T08:58:59Z")

</div>

Hi cherry，  
Thank you very much~  
try your code, swiped left and rihgt works well, but don’t work for up and down.  
And I try to print the “deltaY”,no console.log result when swipe vertical, must have some angle…  
Another querstion, why “ion-swipe-up” wont work? Is it be cancelled, I found it in ionic v1,but not in the laster doc.

---

<div class="post-metadata">

**Author:** ![cherry](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/cherry/32/149370_2.png) [@cherry](https://forum.ionicframework.com/u/cherry)\
**Post date:** [January 26, 2018, 9:06am UTC](https://forum.ionicframework.com/t/unable-to-use-all-swipe-darg-events-but-on-swipe-works/119393/6 "2018-01-26T09:06:30Z")

</div>

I sadly can’t answer that because I don’t know the answer 😁.

Hmm odd what you can do, put this into your code `console.log($e.detlaY);`. Then you can see what numbers you have to use.

```auto
swipeEvent($e) {
console.log($e.detlaY);
  if ($e.deltaX <= -130) {
      console.log('swiped left');
      }else if{
     ($e.deltaX <= 130)
     console.log('swiped right');
     }else if{
    ($e.deltaY <= 130)
     console.log('swiped up');
     }else if{
    ($e.deltaY <= -130)
    console.log('swiped down');
   }
}

```

Good luck!

---

<div class="post-metadata">

**Author:** ![800110](https://avatars.discourse-cdn.com/v4/letter/8/a88e57/32.png) [@800110](https://forum.ionicframework.com/u/800110)\
**Post date:** [January 26, 2018, 11:16am UTC](https://forum.ionicframework.com/t/unable-to-use-all-swipe-darg-events-but-on-swipe-works/119393/7 "2018-01-26T11:16:34Z")

</div>

OK~  
Thank you for your help~

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:53pm UTC](https://forum.ionicframework.com/t/unable-to-use-all-swipe-darg-events-but-on-swipe-works/119393/8 "2021-07-19T21:53:13Z")

</div>

Closed on July 19, 2021, 9:53pm UTC


