|
1 | 1 |
|
2 |
| -import { Injectable } from '@angular/core'; |
3 |
| - |
| 2 | +import { forwardRef, Inject, Injectable } from '@angular/core'; |
4 | 3 | import { App } from '../components/app/app';
|
5 | 4 |
|
6 | 5 | export const enum GesturePriority {
|
@@ -30,12 +29,17 @@ export class GestureController {
|
30 | 29 | private requestedStart: { [eventId: number]: number } = {};
|
31 | 30 | private disabledGestures: { [eventName: string]: Set<number> } = {};
|
32 | 31 | private disabledScroll: Set<number> = new Set<number>();
|
33 |
| - private appRoot: App; |
34 | 32 | private capturedID: number = null;
|
35 | 33 |
|
| 34 | + constructor(@Inject(forwardRef(() => App)) private _app: App) { } |
| 35 | + |
36 | 36 | create(name: string, opts: GestureOptions = {}): GestureDelegate {
|
| 37 | + return new GestureDelegate(name, this.newID(), this, opts); |
| 38 | + } |
| 39 | + |
| 40 | + newID(): number { |
37 | 41 | let id = this.id; this.id++;
|
38 |
| - return new GestureDelegate(name, id, this, opts); |
| 42 | + return id; |
39 | 43 | }
|
40 | 44 |
|
41 | 45 | start(gestureName: string, id: number, priority: number): boolean {
|
@@ -94,16 +98,18 @@ export class GestureController {
|
94 | 98 | disableScroll(id: number) {
|
95 | 99 | let isEnabled = !this.isScrollDisabled();
|
96 | 100 | this.disabledScroll.add(id);
|
97 |
| - if (isEnabled && this.isScrollDisabled()) { |
98 |
| - // this.appRoot.disableScroll = true; |
| 101 | + if (this._app && isEnabled && this.isScrollDisabled()) { |
| 102 | + console.debug('GestureController: Disabling scrolling'); |
| 103 | + this._app.setScrollDisabled(true); |
99 | 104 | }
|
100 | 105 | }
|
101 | 106 |
|
102 | 107 | enableScroll(id: number) {
|
103 | 108 | let isDisabled = this.isScrollDisabled();
|
104 | 109 | this.disabledScroll.delete(id);
|
105 |
| - if (isDisabled && !this.isScrollDisabled()) { |
106 |
| - // this.appRoot.disableScroll = false; |
| 110 | + if (this._app && isDisabled && !this.isScrollDisabled()) { |
| 111 | + console.debug('GestureController: Enabling scrolling'); |
| 112 | + this._app.setScrollDisabled(false); |
107 | 113 | }
|
108 | 114 | }
|
109 | 115 |
|
|
0 commit comments