mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
25 lines
645 B
TypeScript
25 lines
645 B
TypeScript
import { Injectable, NgZone } from '@angular/core';
|
|
import { Gesture, GestureConfig, createGesture } from '@ionic/core';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class GestureController {
|
|
constructor(private zone: NgZone) {}
|
|
/**
|
|
* Create a new gesture
|
|
*/
|
|
create(opts: GestureConfig, runInsideAngularZone = false): Gesture {
|
|
if (runInsideAngularZone) {
|
|
Object.getOwnPropertyNames(opts).forEach(key => {
|
|
if (typeof opts[key] === 'function') {
|
|
const fn = opts[key];
|
|
opts[key] = (...props) => this.zone.run(() => fn(...props));
|
|
}
|
|
});
|
|
}
|
|
|
|
return createGesture(opts);
|
|
}
|
|
}
|