mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +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,
|
||||
// add a cancel and ok button to the picker
|
||||
if (pickerOptions.buttons.length === 0) {
|
||||
pickerOptions.buttons = [{
|
||||
text: this.cancelText,
|
||||
role: 'cancel',
|
||||
handler: () => this.ionCancel.emit(this)
|
||||
}, {
|
||||
text: this.doneText,
|
||||
handler: (data: any) => this.value = data,
|
||||
}];
|
||||
const buttons = pickerOptions.buttons;
|
||||
if (!buttons || buttons.length === 0) {
|
||||
pickerOptions.buttons = [
|
||||
{
|
||||
text: this.cancelText,
|
||||
role: 'cancel',
|
||||
handler: () => this.ionCancel.emit(this)
|
||||
},
|
||||
{
|
||||
text: this.doneText,
|
||||
handler: (data: any) => this.value = data,
|
||||
}];
|
||||
}
|
||||
|
||||
pickerOptions.columns = this.generateColumns();
|
||||
|
@ -52,10 +52,11 @@ export class FabButton {
|
||||
@Prop() disabled = false;
|
||||
|
||||
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.inContainer = (parentNode === 'ION-FAB');
|
||||
this.inList = (parentTag === 'ION-FAB-LIST');
|
||||
this.inContainer = (parentTag === 'ION-FAB');
|
||||
}
|
||||
|
||||
|
||||
|
@ -125,14 +125,17 @@ export class GestureController {
|
||||
|
||||
|
||||
export class GestureDelegate {
|
||||
private ctrl: GestureController|null;
|
||||
|
||||
constructor(
|
||||
private ctrl: GestureController,
|
||||
ctrl: GestureController,
|
||||
private gestureDelegateId: number,
|
||||
private name: string,
|
||||
private priority: number,
|
||||
private disableScroll: boolean
|
||||
) { }
|
||||
) {
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
canStart(): boolean {
|
||||
if (!this.ctrl) {
|
||||
@ -185,47 +188,51 @@ export class BlockerDelegate {
|
||||
|
||||
blocked = false;
|
||||
|
||||
private ctrl: GestureController|null;
|
||||
|
||||
constructor(
|
||||
private blockerDelegateId: number,
|
||||
private controller: GestureController,
|
||||
private disable: string[],
|
||||
ctrl: GestureController,
|
||||
private disable: string[] | undefined,
|
||||
private disableScroll: boolean
|
||||
) { }
|
||||
) {
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
block() {
|
||||
if (!this.controller) {
|
||||
if (!this.ctrl) {
|
||||
return;
|
||||
}
|
||||
if (this.disable) {
|
||||
this.disable.forEach(gesture => {
|
||||
this.controller.disableGesture(gesture, this.blockerDelegateId);
|
||||
});
|
||||
for (const gesture of this.disable) {
|
||||
this.ctrl.disableGesture(gesture, this.blockerDelegateId);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.disableScroll) {
|
||||
this.controller.disableScroll(this.blockerDelegateId);
|
||||
this.ctrl.disableScroll(this.blockerDelegateId);
|
||||
}
|
||||
this.blocked = true;
|
||||
}
|
||||
|
||||
unblock() {
|
||||
if (!this.controller) {
|
||||
if (!this.ctrl) {
|
||||
return;
|
||||
}
|
||||
if (this.disable) {
|
||||
this.disable.forEach(gesture => {
|
||||
this.controller.enableGesture(gesture, this.blockerDelegateId);
|
||||
});
|
||||
for (const gesture of this.disable) {
|
||||
this.ctrl.enableGesture(gesture, this.blockerDelegateId);
|
||||
}
|
||||
}
|
||||
if (this.disableScroll) {
|
||||
this.controller.enableScroll(this.blockerDelegateId);
|
||||
this.ctrl.enableScroll(this.blockerDelegateId);
|
||||
}
|
||||
this.blocked = false;
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.unblock();
|
||||
this.controller = null;
|
||||
this.ctrl = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
|
||||
|
||||
export class PanRecognizer {
|
||||
private startX: number;
|
||||
private startY: number;
|
||||
|
@ -104,7 +104,7 @@ export class InfiniteScroll {
|
||||
this.thresholdChanged(this.threshold);
|
||||
this.enableScrollEvents(!this.disabled);
|
||||
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})
|
||||
protected onScroll(ev: CustomEvent) {
|
||||
const scrollEl = this.scrollEl;
|
||||
const detail = ev.detail as ScrollDetail;
|
||||
if (!this.canStart()) {
|
||||
if (!scrollEl || !this.canStart()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -125,8 +126,8 @@ export class InfiniteScroll {
|
||||
return 2;
|
||||
}
|
||||
const scrollTop = detail.scrollTop;
|
||||
const scrollHeight = this.scrollEl.scrollHeight;
|
||||
const height = this.scrollEl.offsetHeight;
|
||||
const scrollHeight = scrollEl.scrollHeight;
|
||||
const height = scrollEl.offsetHeight;
|
||||
const threshold = this.thrPc ? (height * this.thrPc) : this.thrPx;
|
||||
|
||||
const distanceFromInfinite = (this.position === Position.Bottom)
|
||||
@ -159,7 +160,8 @@ export class InfiniteScroll {
|
||||
*/
|
||||
@Method()
|
||||
complete() {
|
||||
if (!this.isLoading) {
|
||||
const scrollEl = this.scrollEl;
|
||||
if (!this.isLoading || !scrollEl) {
|
||||
return;
|
||||
}
|
||||
this.isLoading = false;
|
||||
@ -187,18 +189,18 @@ export class InfiniteScroll {
|
||||
this.isBusy = true;
|
||||
// ******** DOM READ ****************
|
||||
// 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 ****************
|
||||
this.dom.read(() => {
|
||||
// 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
|
||||
const newScrollTop = scrollHeight - prev;
|
||||
|
||||
// ******** DOM WRITE ****************
|
||||
this.dom.write(() => {
|
||||
this.scrollEl.scrollTop = newScrollTop;
|
||||
scrollEl.scrollTop = newScrollTop;
|
||||
this.isBusy = false;
|
||||
});
|
||||
});
|
||||
@ -224,7 +226,9 @@ export class InfiniteScroll {
|
||||
}
|
||||
|
||||
private enableScrollEvents(shouldListen: boolean) {
|
||||
this.enableListener(this, 'ionScroll', shouldListen, this.scrollEl);
|
||||
if (this.scrollEl) {
|
||||
this.enableListener(this, 'ionScroll', shouldListen, this.scrollEl);
|
||||
}
|
||||
}
|
||||
|
||||
hostData() {
|
||||
|
@ -204,7 +204,7 @@ export class Input implements InputComponent {
|
||||
@Watch('value')
|
||||
protected valueChanged() {
|
||||
const inputEl = this.el.querySelector('input');
|
||||
if (inputEl.value !== this.value) {
|
||||
if (inputEl && inputEl.value !== this.value) {
|
||||
inputEl.value = this.value;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ export interface NavElement extends HTMLElement {
|
||||
export interface RouterEntry {
|
||||
path: string;
|
||||
id: any;
|
||||
segments: string[];
|
||||
segments?: string[];
|
||||
props?: any;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user