ng-swipe
v2.0.1
Published
An Angular directive wrapper for a lightweight library to detect swipes on touchscreen devices.
Downloads
719
Maintainers
Readme
This library is an Angular directive wrapper around the vanilla JS swipe detection library ag-swipe-core
.
For more details on the public interface of the library please see the Github page.
Installation
npm install ng-swipe --save
Usage
import { SwipeModule } from 'ng-swipe';
@NgModule({
imports: [
SwipeModule
],
})
import { SwipeEvent } from 'ng-swipe';
@Component({
selector: 'app',
template: `
<div
ngSwipe
(swipeMove)="onSwipeMove($event)"
(swipeEnd)="onSwipeEnd($event)"
>Swipe me!</div>
`
})
export class AppComponent {
onSwipeMove(event: SwipeEvent) {
console.log(`SwipeMove direction: ${event.direction} and distance: ${event.distance}`);
}
onSwipeEnd(event: SwipeEvent) {
console.log(`SwipeEnd direction: ${event.direction} and distance: ${event.distance}`);
}
}