Skip to content

Commit f0a5d27

Browse files
authored
refactor(angular): gesture controller uses correct core instance (#28477)
Issue number: Internal --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> The `GestureController` provider does not use the correct underlying instance of the utilities from either the lazy or custom elements build, depending on if the developer is using `@ionic/angular` or `@ionic/angular/standalone`. It will always use the lazy instance. This applied to the `createGesture` function. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - `GestureController` uses the instance of the utilities based on it's implementation type, e.g. `@ionic/angular/standalone` uses the custom elements build with the utilities from `@ionic/core/components`. - `@ionic/angular` and `@ionic/angular/standalone` now export their own specific implementation of `GestureController` ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. -->
1 parent fbc9f53 commit f0a5d27

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

packages/angular/common/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ export { AlertController } from './providers/alert-controller';
22
export { LoadingController } from './providers/loading-controller';
33
export { MenuController } from './providers/menu-controller';
44
export { PickerController } from './providers/picker-controller';
5-
6-
export { GestureController } from './providers/gesture-controller';
75
export { DomController } from './providers/dom-controller';
86
export { NavController } from './providers/nav-controller';
97

packages/angular/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export {
2323
AlertController,
2424
LoadingController,
2525
PickerController,
26-
GestureController,
2726
DomController,
2827
NavController,
2928
Config,
@@ -38,6 +37,7 @@ export {
3837
} from '@ionic/angular/common';
3938
export { AnimationController } from './providers/animation-controller';
4039
export { ActionSheetController } from './providers/action-sheet-controller';
40+
export { GestureController } from './providers/gesture-controller';
4141
export { MenuController } from './providers/menu-controller';
4242
export { ModalController } from './providers/modal-controller';
4343
export { PopoverController } from './providers/popover-controller';
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Injectable, NgZone } from '@angular/core';
2+
import type { Gesture, GestureConfig } from '@ionic/core';
3+
import { createGesture } from '@ionic/core';
4+
5+
@Injectable({
6+
providedIn: 'root',
7+
})
8+
export class GestureController {
9+
constructor(private zone: NgZone) {}
10+
/**
11+
* Create a new gesture
12+
*/
13+
create(opts: GestureConfig, runInsideAngularZone = false): Gesture {
14+
if (runInsideAngularZone) {
15+
Object.getOwnPropertyNames(opts).forEach((key) => {
16+
if (typeof opts[key] === 'function') {
17+
const fn = opts[key];
18+
opts[key] = (...props: any[]) => this.zone.run(() => fn(...props));
19+
}
20+
});
21+
}
22+
23+
return createGesture(opts);
24+
}
25+
}

packages/angular/standalone/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export { IonTabs } from './navigation/tabs';
77
export { provideIonicAngular } from './providers/ionic-angular';
88
export { ActionSheetController } from './providers/action-sheet-controller';
99
export { AnimationController } from './providers/animation-controller';
10+
export { GestureController } from './providers/gesture-controller';
1011
export { MenuController } from './providers/menu-controller';
1112
export { ModalController } from './providers/modal-controller';
1213
export { PopoverController } from './providers/popover-controller';
@@ -15,7 +16,6 @@ export {
1516
AlertController,
1617
LoadingController,
1718
PickerController,
18-
GestureController,
1919
DomController,
2020
NavController,
2121
Config,

packages/angular/common/src/providers/gesture-controller.ts renamed to packages/angular/standalone/src/providers/gesture-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NgZone, Injectable } from '@angular/core';
1+
import { Injectable, NgZone } from '@angular/core';
22
import type { Gesture, GestureConfig } from '@ionic/core/components';
33
import { createGesture } from '@ionic/core/components';
44

0 commit comments

Comments
 (0)