mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 13:32:54 +08:00
chore(): more ts strict fixes
This commit is contained in:
@ -232,15 +232,18 @@ export class Datetime {
|
|||||||
|
|
||||||
// If the user has not passed in picker buttons,
|
// If the user has not passed in picker buttons,
|
||||||
// add a cancel and ok button to the picker
|
// add a cancel and ok button to the picker
|
||||||
if (pickerOptions.buttons.length === 0) {
|
const buttons = pickerOptions.buttons;
|
||||||
pickerOptions.buttons = [{
|
if (!buttons || buttons.length === 0) {
|
||||||
text: this.cancelText,
|
pickerOptions.buttons = [
|
||||||
role: 'cancel',
|
{
|
||||||
handler: () => this.ionCancel.emit(this)
|
text: this.cancelText,
|
||||||
}, {
|
role: 'cancel',
|
||||||
text: this.doneText,
|
handler: () => this.ionCancel.emit(this)
|
||||||
handler: (data: any) => this.value = data,
|
},
|
||||||
}];
|
{
|
||||||
|
text: this.doneText,
|
||||||
|
handler: (data: any) => this.value = data,
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
pickerOptions.columns = this.generateColumns();
|
pickerOptions.columns = this.generateColumns();
|
||||||
|
@ -52,10 +52,11 @@ export class FabButton {
|
|||||||
@Prop() disabled = false;
|
@Prop() disabled = false;
|
||||||
|
|
||||||
componentDidLoad() {
|
componentDidLoad() {
|
||||||
const parentNode = this.el.parentNode.nodeName;
|
const parentNode = this.el.parentNode;
|
||||||
|
const parentTag = parentNode ? parentNode.nodeName : null;
|
||||||
|
|
||||||
this.inList = (parentNode === 'ION-FAB-LIST');
|
this.inList = (parentTag === 'ION-FAB-LIST');
|
||||||
this.inContainer = (parentNode === 'ION-FAB');
|
this.inContainer = (parentTag === 'ION-FAB');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,14 +125,17 @@ export class GestureController {
|
|||||||
|
|
||||||
|
|
||||||
export class GestureDelegate {
|
export class GestureDelegate {
|
||||||
|
private ctrl: GestureController|null;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private ctrl: GestureController,
|
ctrl: GestureController,
|
||||||
private gestureDelegateId: number,
|
private gestureDelegateId: number,
|
||||||
private name: string,
|
private name: string,
|
||||||
private priority: number,
|
private priority: number,
|
||||||
private disableScroll: boolean
|
private disableScroll: boolean
|
||||||
) { }
|
) {
|
||||||
|
this.ctrl = ctrl;
|
||||||
|
}
|
||||||
|
|
||||||
canStart(): boolean {
|
canStart(): boolean {
|
||||||
if (!this.ctrl) {
|
if (!this.ctrl) {
|
||||||
@ -185,47 +188,51 @@ export class BlockerDelegate {
|
|||||||
|
|
||||||
blocked = false;
|
blocked = false;
|
||||||
|
|
||||||
|
private ctrl: GestureController|null;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private blockerDelegateId: number,
|
private blockerDelegateId: number,
|
||||||
private controller: GestureController,
|
ctrl: GestureController,
|
||||||
private disable: string[],
|
private disable: string[] | undefined,
|
||||||
private disableScroll: boolean
|
private disableScroll: boolean
|
||||||
) { }
|
) {
|
||||||
|
this.ctrl = ctrl;
|
||||||
|
}
|
||||||
|
|
||||||
block() {
|
block() {
|
||||||
if (!this.controller) {
|
if (!this.ctrl) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.disable) {
|
if (this.disable) {
|
||||||
this.disable.forEach(gesture => {
|
for (const gesture of this.disable) {
|
||||||
this.controller.disableGesture(gesture, this.blockerDelegateId);
|
this.ctrl.disableGesture(gesture, this.blockerDelegateId);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.disableScroll) {
|
if (this.disableScroll) {
|
||||||
this.controller.disableScroll(this.blockerDelegateId);
|
this.ctrl.disableScroll(this.blockerDelegateId);
|
||||||
}
|
}
|
||||||
this.blocked = true;
|
this.blocked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unblock() {
|
unblock() {
|
||||||
if (!this.controller) {
|
if (!this.ctrl) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.disable) {
|
if (this.disable) {
|
||||||
this.disable.forEach(gesture => {
|
for (const gesture of this.disable) {
|
||||||
this.controller.enableGesture(gesture, this.blockerDelegateId);
|
this.ctrl.enableGesture(gesture, this.blockerDelegateId);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
if (this.disableScroll) {
|
if (this.disableScroll) {
|
||||||
this.controller.enableScroll(this.blockerDelegateId);
|
this.ctrl.enableScroll(this.blockerDelegateId);
|
||||||
}
|
}
|
||||||
this.blocked = false;
|
this.blocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
this.unblock();
|
this.unblock();
|
||||||
this.controller = null;
|
this.ctrl = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
export class PanRecognizer {
|
export class PanRecognizer {
|
||||||
private startX: number;
|
private startX: number;
|
||||||
private startY: number;
|
private startY: number;
|
||||||
|
@ -104,7 +104,7 @@ export class InfiniteScroll {
|
|||||||
this.thresholdChanged(this.threshold);
|
this.thresholdChanged(this.threshold);
|
||||||
this.enableScrollEvents(!this.disabled);
|
this.enableScrollEvents(!this.disabled);
|
||||||
if (this.position === Position.Top) {
|
if (this.position === Position.Top) {
|
||||||
this.dom.write(() => this.scrollEl.scrollToBottom(0));
|
this.dom.write(() => this.scrollEl && this.scrollEl.scrollToBottom(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,8 +114,9 @@ export class InfiniteScroll {
|
|||||||
|
|
||||||
@Listen('ionScroll', {enabled: false})
|
@Listen('ionScroll', {enabled: false})
|
||||||
protected onScroll(ev: CustomEvent) {
|
protected onScroll(ev: CustomEvent) {
|
||||||
|
const scrollEl = this.scrollEl;
|
||||||
const detail = ev.detail as ScrollDetail;
|
const detail = ev.detail as ScrollDetail;
|
||||||
if (!this.canStart()) {
|
if (!scrollEl || !this.canStart()) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,8 +126,8 @@ export class InfiniteScroll {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
const scrollTop = detail.scrollTop;
|
const scrollTop = detail.scrollTop;
|
||||||
const scrollHeight = this.scrollEl.scrollHeight;
|
const scrollHeight = scrollEl.scrollHeight;
|
||||||
const height = this.scrollEl.offsetHeight;
|
const height = scrollEl.offsetHeight;
|
||||||
const threshold = this.thrPc ? (height * this.thrPc) : this.thrPx;
|
const threshold = this.thrPc ? (height * this.thrPc) : this.thrPx;
|
||||||
|
|
||||||
const distanceFromInfinite = (this.position === Position.Bottom)
|
const distanceFromInfinite = (this.position === Position.Bottom)
|
||||||
@ -159,7 +160,8 @@ export class InfiniteScroll {
|
|||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
complete() {
|
complete() {
|
||||||
if (!this.isLoading) {
|
const scrollEl = this.scrollEl;
|
||||||
|
if (!this.isLoading || !scrollEl) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
@ -187,18 +189,18 @@ export class InfiniteScroll {
|
|||||||
this.isBusy = true;
|
this.isBusy = true;
|
||||||
// ******** DOM READ ****************
|
// ******** DOM READ ****************
|
||||||
// Save the current content dimensions before the UI updates
|
// Save the current content dimensions before the UI updates
|
||||||
const prev = this.scrollEl.scrollHeight - this.scrollEl.scrollTop;
|
const prev = scrollEl.scrollHeight - scrollEl.scrollTop;
|
||||||
|
|
||||||
// ******** DOM READ ****************
|
// ******** DOM READ ****************
|
||||||
this.dom.read(() => {
|
this.dom.read(() => {
|
||||||
// UI has updated, save the new content dimensions
|
// UI has updated, save the new content dimensions
|
||||||
const scrollHeight = this.scrollEl.scrollHeight;
|
const scrollHeight = scrollEl.scrollHeight;
|
||||||
// New content was added on top, so the scroll position should be changed immediately to prevent it from jumping around
|
// New content was added on top, so the scroll position should be changed immediately to prevent it from jumping around
|
||||||
const newScrollTop = scrollHeight - prev;
|
const newScrollTop = scrollHeight - prev;
|
||||||
|
|
||||||
// ******** DOM WRITE ****************
|
// ******** DOM WRITE ****************
|
||||||
this.dom.write(() => {
|
this.dom.write(() => {
|
||||||
this.scrollEl.scrollTop = newScrollTop;
|
scrollEl.scrollTop = newScrollTop;
|
||||||
this.isBusy = false;
|
this.isBusy = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -224,7 +226,9 @@ export class InfiniteScroll {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private enableScrollEvents(shouldListen: boolean) {
|
private enableScrollEvents(shouldListen: boolean) {
|
||||||
this.enableListener(this, 'ionScroll', shouldListen, this.scrollEl);
|
if (this.scrollEl) {
|
||||||
|
this.enableListener(this, 'ionScroll', shouldListen, this.scrollEl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hostData() {
|
hostData() {
|
||||||
|
@ -204,7 +204,7 @@ export class Input implements InputComponent {
|
|||||||
@Watch('value')
|
@Watch('value')
|
||||||
protected valueChanged() {
|
protected valueChanged() {
|
||||||
const inputEl = this.el.querySelector('input');
|
const inputEl = this.el.querySelector('input');
|
||||||
if (inputEl.value !== this.value) {
|
if (inputEl && inputEl.value !== this.value) {
|
||||||
inputEl.value = this.value;
|
inputEl.value = this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ export interface NavElement extends HTMLElement {
|
|||||||
export interface RouterEntry {
|
export interface RouterEntry {
|
||||||
path: string;
|
path: string;
|
||||||
id: any;
|
id: any;
|
||||||
segments: string[];
|
segments?: string[];
|
||||||
props?: any;
|
props?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user