4

I wants to allow horizontal swipe event and keep vertical scroll. So use this:

touch-action: pan-y !important;

But Safari do not support "touch-action". HammerJS preventDefaults cannot detect the "touch-action: pan-y" css, therefore it prevented the scroll.

As a result, the swipe is work nice, but cannot scroll Safari. Both swipe and scroll work on other browser which support "touch-action".

I am using angular2.

<div (swipeleft)="swipe($event)" (swiperight)="swipe($event)">

Please help! Is there any config I am missing.

1
  • I'm having this issue as well.. bummer! :\
    – Elron
    Commented Sep 28, 2018 at 22:53

1 Answer 1

1

I found a solution

1) Add this to app.module.ts

export class BaluHammerConfig extends HammerGestureConfig {
    overrides = {
        pan: {
             direction: 6
      },
      pinch: {
          enable: false
      },
      rotate: {
          enable: false
      }
  };
}

2) instead of adding HammerGestureConfig to your providers, use this:

{
    provide: HAMMER_GESTURE_CONFIG,
    useClass: BaluHammerConfig
},
2
  • Not sure if you verified this in safari, but it does not work. Commented Feb 15, 2019 at 0:05
  • Never mind, it actually worked, My browser was not picking up changes Commented Feb 15, 2019 at 0:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.