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. -->
This commit is contained in:
Sean Perkins
2023-11-09 21:02:29 -05:00
committed by GitHub
parent fbc9f53d35
commit f0a5d2704c
5 changed files with 28 additions and 5 deletions

View File

@@ -2,8 +2,6 @@ export { AlertController } from './providers/alert-controller';
export { LoadingController } from './providers/loading-controller';
export { MenuController } from './providers/menu-controller';
export { PickerController } from './providers/picker-controller';
export { GestureController } from './providers/gesture-controller';
export { DomController } from './providers/dom-controller';
export { NavController } from './providers/nav-controller';

View File

@@ -23,7 +23,6 @@ export {
AlertController,
LoadingController,
PickerController,
GestureController,
DomController,
NavController,
Config,
@@ -38,6 +37,7 @@ export {
} from '@ionic/angular/common';
export { AnimationController } from './providers/animation-controller';
export { ActionSheetController } from './providers/action-sheet-controller';
export { GestureController } from './providers/gesture-controller';
export { MenuController } from './providers/menu-controller';
export { ModalController } from './providers/modal-controller';
export { PopoverController } from './providers/popover-controller';

View File

@@ -0,0 +1,25 @@
import { Injectable, NgZone } from '@angular/core';
import type { Gesture, GestureConfig } from '@ionic/core';
import { 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: any[]) => this.zone.run(() => fn(...props));
}
});
}
return createGesture(opts);
}
}

View File

@@ -7,6 +7,7 @@ export { IonTabs } from './navigation/tabs';
export { provideIonicAngular } from './providers/ionic-angular';
export { ActionSheetController } from './providers/action-sheet-controller';
export { AnimationController } from './providers/animation-controller';
export { GestureController } from './providers/gesture-controller';
export { MenuController } from './providers/menu-controller';
export { ModalController } from './providers/modal-controller';
export { PopoverController } from './providers/popover-controller';
@@ -15,7 +16,6 @@ export {
AlertController,
LoadingController,
PickerController,
GestureController,
DomController,
NavController,
Config,

View File

@@ -1,4 +1,4 @@
import { NgZone, Injectable } from '@angular/core';
import { Injectable, NgZone } from '@angular/core';
import type { Gesture, GestureConfig } from '@ionic/core/components';
import { createGesture } from '@ionic/core/components';