user9088454
user9088454

Reputation: 1122

How to add / import / install Gesture in ionic 4?

I try to create sliding segments using this example. This example in ionic 3 and I want to make it work for ionic 4 and in this example, he is using Gesture. But the problem is I am not able to import Gesture.

in example imported this Ionic v3:

import { Gesture } from 'ionic-angular/gestures/gesture';

so as we importing other @ionic/angular but showing error:

import { Gesture } from '@ionic/angular/gestures/gesture';

Error: Cannot find module '@ionic/angular/gestures/gesture'.ts(2307)

In short, I just want to import gestures in my ionic 4 projects. Please help.

Upvotes: 1

Views: 3533

Answers (1)

Phonolog
Phonolog

Reputation: 6511

The Ionic team is working on adding gesture support to Ionic v4 right now. See this issue in on Github and especially this comment.

Ionic is moving from HammerJS-based gestures towards a custom solution, so I'd either subscribe to the issue above and wait for the feature to be completed or you can install and use HammerJS.

Latter is described in detail here. First, you need to install HammerJS via npm:

npm install hammerjs

Then you'll have to add the following import to your main.ts:

import 'hammerjs';

Then you should be able to use gesture bindings, as you're used to, e.g.:

<div (swipe)="onSwipe($event)"></div>

The blog post mentioned above offers some more examples and also a list of available events.

Upvotes: 3

Related Questions