fix(gestures): gesture controller handled by components

* fix(gestures): gesture controller is handled by components

fixes #9046

* fix(gestures): adds hybrid disable scroll assistance

fixes #9130
fixes #9052
fixes #7444
This commit is contained in:
Manu Mtz.-Almeida
2016-11-16 17:03:51 +01:00
committed by Adam Bradley
parent 339857af1e
commit 32ab817181
26 changed files with 534 additions and 272 deletions

View File

@ -4,7 +4,8 @@ import { Config } from '../../config/config';
import { Key } from '../../util/key';
import { NavParams } from '../../navigation/nav-params';
import { ViewController } from '../../navigation/view-controller';
import { GestureController, BlockerDelegate, BLOCK_ALL } from '../../gestures/gesture-controller';
import { assert } from '../../util/util';
/**
* @private
@ -12,7 +13,7 @@ import { ViewController } from '../../navigation/view-controller';
@Component({
selector: 'ion-popover',
template:
'<ion-backdrop (click)="_bdClick()" [class.hide-backdrop]="!d.showBackdrop"></ion-backdrop>' +
'<ion-backdrop (click)="_bdClick()" [hidden]="!d.showBackdrop"></ion-backdrop>' +
'<div class="popover-wrapper">' +
'<div class="popover-arrow"></div>' +
'<div class="popover-content">' +
@ -32,10 +33,9 @@ export class PopoverCmp {
enableBackdropDismiss?: boolean;
};
/** @private */
_enabled: boolean;
_gestureBlocker: BlockerDelegate;
/** @private */
id: number;
constructor(
@ -44,8 +44,10 @@ export class PopoverCmp {
public _renderer: Renderer,
public _config: Config,
public _navParams: NavParams,
public _viewCtrl: ViewController
public _viewCtrl: ViewController,
gestureCtrl: GestureController,
) {
this._gestureBlocker = gestureCtrl.createBlocker(BLOCK_ALL);
this.d = _navParams.data.opts;
_renderer.setElementClass(_elementRef.nativeElement, `popover-${_config.get('mode')}`, true);
@ -62,13 +64,11 @@ export class PopoverCmp {
ionViewPreLoad() {
let activeElement: any = document.activeElement;
if (document.activeElement) {
activeElement.blur();
}
activeElement && activeElement.blur();
this._load(this._navParams.data.component);
}
/** @private */
_load(component: any) {
if (component) {
const componentFactory = this._cfr.resolveComponentFactory(component);
@ -76,12 +76,23 @@ export class PopoverCmp {
// ******** DOM WRITE ****************
const componentRef = this._viewport.createComponent(componentFactory, this._viewport.length, this._viewport.parentInjector, []);
this._viewCtrl._setInstance(componentRef.instance);
this._enabled = true;
// Subscribe to events in order to block gestures
// TODO, should we unsubscribe? memory leak?
this._viewCtrl.willEnter.subscribe(this._viewWillEnter.bind(this));
this._viewCtrl.didLeave.subscribe(this._viewDidLeave.bind(this));
}
}
/** @private */
_viewWillEnter() {
this._gestureBlocker.block();
}
_viewDidLeave() {
this._gestureBlocker.unblock();
}
_setCssClass(componentRef: any, className: string) {
this._renderer.setElementClass(componentRef.location.nativeElement, className, true);
}
@ -98,6 +109,11 @@ export class PopoverCmp {
this._bdClick();
}
}
ngOnDestroy() {
assert(this._gestureBlocker.blocked === false, 'gesture blocker must be already unblocked');
this._gestureBlocker.destroy();
}
}
let popoverIds = -1;