我想允许水平滑动事件并保持垂直滚动。
所以使用这个:
touch-action: pan-y !important;
但 Safari 不支持“触摸 Action ”。
HammerJS preventDefaults 无法检测“touch-action: pan-y”css,因此它阻止了滚动。
因此,滑动效果很好,但无法滚动 Safari。在其他支持“触摸 Action ”的浏览器上滑动和滚动都可以工作。
我正在使用 angular2。
<div (swipeleft)="swipe($event)" (swiperight)="swipe($event)">
请帮忙!有没有我遗漏的配置。
最佳答案
我找到了解决方案
1) 将此添加到 app.module.ts
export class BaluHammerConfig extends HammerGestureConfig {
overrides = {
pan: {
direction: 6
},
pinch: {
enable: false
},
rotate: {
enable: false
}
};
}
2) 而不是将 HammerGestureConfig 添加到您的提供者,使用这个:
{
provide: HAMMER_GESTURE_CONFIG,
useClass: BaluHammerConfig
},
关于angularjs - Safari 中的 Hammerjs : scroll issue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51815182/