HammerJS Swipe在设备模式下无法在移动设备或Google Chrome上运行

时间:2019-05-22 18:36:04

标签: angular google-chrome google-chrome-devtools hammer.js

我有一个简单的代码可滑动该网站,当我在桌面版Google Chrome上进行测试时,它可以正常工作,但是当我要在移动设备或Google Chrome DevTools Device Mode上进行测试时,则无法正常工作。< / p>

我尝试更改HammerGestureConfig覆盖的值,但是当我尝试更改为swipeleft或swiperight时,出现错误,仅接受滑动覆盖。

...
import * as Hammer from 'hammerjs';
import { HammerGestureConfig, HAMMER_GESTURE_CONFIG, BrowserModule } from '@angular/platform-browser';
import { SwipeComponent } from './components/swipe/swipe.component';

export class HammerConfig extends HammerGestureConfig {
  overrides = {
    swipe: { direction: Hammer.DIRECTION_ALL },
  } as any;
}

@NgModule({
  declarations: [
    ...
    SwipeComponent,
  ],
  ...
  providers: [
    AuthService,
    {
      provide: HAMMER_GESTURE_CONFIG,
      useClass: HammerConfig
    }
  ],
})
export class AppModule { }

<div
  (swipeleft)="navigateForwardTo(forward)"
  (swiperight)="navigateBackTo(back)">
  <ng-content></ng-content>
  <app-navigation-arrows 
    [back]="back"
    [backEnabled]="backEnabled"
    [forwardEnabled]="forwardEnabled"
    [forward]="forward">
  </app-navigation-arrows>
</div>

1 个答案:

答案 0 :(得分:0)

我不得不将inputClass更改为Hammer.TouchInput

widget.values = widget.options[<index>]