0

I want to reset my panning value. Basicly what i want todo is when the value hits -130 it should put the panning value to 0 again.

My code:

swipeEvent($e) {
  if ($e.deltaX <= -130) {
      document.getElementById("button").click();
      console.log('swiped left')
      };
  if ($e.deltaX < -131) { $e.deltaX == 0 }
}

I tried it with this code already:

if ($e.deltaX < -131) { $e.deltaX = 0 }

sadly this didn't worked.

Could someone help me please ? Regards!

CupOfTea
  • 173
  • 1
  • 11

1 Answers1

0

I fixed it!

I just had to change the HTML from this:

<div class="cards" (pan)='swipeEvent($event)'>

to this:

<div class="cards" (swipe)='swipeEvent($event)'>

TS:

swipeEvent($e) {
  if ($e.deltaX <= -130) {
      document.getElementById("button").click();
      console.log('swiped left')
      };
}

Hope this helps someone in the future!

CupOfTea
  • 173
  • 1
  • 11