mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 21:15:24 +08:00
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:

committed by
Adam Bradley

parent
339857af1e
commit
32ab817181
@ -1,10 +1,11 @@
|
||||
import { Component, ElementRef, Renderer, ViewEncapsulation } from '@angular/core';
|
||||
|
||||
import { Config } from '../../config/config';
|
||||
import { isDefined, isUndefined } from '../../util/util';
|
||||
import { isDefined, isUndefined, assert } from '../../util/util';
|
||||
import { NavParams } from '../../navigation/nav-params';
|
||||
import { ViewController } from '../../navigation/view-controller';
|
||||
import { LoadingOptions } from './loading-options';
|
||||
import { BlockerDelegate, GestureController, BLOCK_ALL } from '../../gestures/gesture-controller';
|
||||
|
||||
/**
|
||||
* @private
|
||||
@ -12,7 +13,7 @@ import { LoadingOptions } from './loading-options';
|
||||
@Component({
|
||||
selector: 'ion-loading',
|
||||
template:
|
||||
'<ion-backdrop [class.hide-backdrop]="!d.showBackdrop"></ion-backdrop>' +
|
||||
'<ion-backdrop [hidden]="!d.showBackdrop"></ion-backdrop>' +
|
||||
'<div class="loading-wrapper">' +
|
||||
'<div *ngIf="showSpinner" class="loading-spinner">' +
|
||||
'<ion-spinner [name]="d.spinner"></ion-spinner>' +
|
||||
@ -29,14 +30,17 @@ export class LoadingCmp {
|
||||
id: number;
|
||||
showSpinner: boolean;
|
||||
durationTimeout: number;
|
||||
gestureBlocker: BlockerDelegate;
|
||||
|
||||
constructor(
|
||||
private _viewCtrl: ViewController,
|
||||
private _config: Config,
|
||||
private _elementRef: ElementRef,
|
||||
gestureCtrl: GestureController,
|
||||
params: NavParams,
|
||||
renderer: Renderer
|
||||
) {
|
||||
this.gestureBlocker = gestureCtrl.createBlocker(BLOCK_ALL);
|
||||
this.d = params.data;
|
||||
|
||||
renderer.setElementClass(_elementRef.nativeElement, `loading-${_config.get('mode')}`, true);
|
||||
@ -62,17 +66,21 @@ export class LoadingCmp {
|
||||
this.showSpinner = isDefined(this.d.spinner) && this.d.spinner !== 'hide';
|
||||
}
|
||||
|
||||
ionViewWillEnter() {
|
||||
this.gestureBlocker.block();
|
||||
}
|
||||
|
||||
ionViewDidLeave() {
|
||||
this.gestureBlocker.unblock();
|
||||
}
|
||||
|
||||
ionViewDidEnter() {
|
||||
let activeElement: any = document.activeElement;
|
||||
if (document.activeElement) {
|
||||
activeElement.blur();
|
||||
}
|
||||
activeElement && activeElement.blur();
|
||||
|
||||
// If there is a duration, dismiss after that amount of time
|
||||
if ( this.d && this.d.duration ) {
|
||||
this.durationTimeout = (<any> setTimeout( () => {
|
||||
this.dismiss('backdrop');
|
||||
}, this.d.duration));
|
||||
this.durationTimeout = setTimeout(() => this.dismiss('backdrop'), this.d.duration);
|
||||
}
|
||||
|
||||
}
|
||||
@ -83,6 +91,11 @@ export class LoadingCmp {
|
||||
}
|
||||
return this._viewCtrl.dismiss(null, role);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
assert(this.gestureBlocker.blocked === false, 'gesture blocker must be already unblocked');
|
||||
this.gestureBlocker.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
let loadingIds = -1;
|
||||
|
Reference in New Issue
Block a user