octicon-rss(16/)
You've already forked ionic-framework
mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 22:44:13 +08:00
refactor(all): strict boolean conditions
This commit is contained in:
octicon-git-branch(16/)
octicon-tag(16/)
octicon-diff(16/tw-mr-1) 96 changed files with 990 additions and 962 deletions
@@ -17,10 +17,8 @@ export function enableHideCaretOnScroll(componentEl: HTMLElement, inputEl: HTMLI
|
||||
const hideCaret = () => scrollHideCaret(true);
|
||||
const showCaret = () => scrollHideCaret(false);
|
||||
|
||||
if (scrollEl) {
|
||||
scrollEl.addEventListener('ionScrollStart', hideCaret);
|
||||
scrollEl.addEventListener('ionScrollEnd', showCaret);
|
||||
}
|
||||
scrollEl.addEventListener('ionScrollStart', hideCaret);
|
||||
scrollEl.addEventListener('ionScrollEnd', showCaret);
|
||||
inputEl.addEventListener('blur', onBlur);
|
||||
|
||||
return () => {
|
||||
|
||||
@@ -21,7 +21,7 @@ export function enableInputBlurring(doc: Document) {
|
||||
didScroll = false;
|
||||
return;
|
||||
}
|
||||
const active = doc.activeElement as HTMLElement;
|
||||
const active = doc.activeElement as HTMLElement | null;
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ function jsSetFocus(
|
||||
inputEl.focus();
|
||||
|
||||
// scroll the input into place
|
||||
// tslint:disable-next-line:no-floating-promises
|
||||
contentEl.scrollByPoint(0, scrollData.scrollAmount, scrollData.scrollDuration).then(() => {
|
||||
// the scroll view is in the correct position now
|
||||
// give the native text input focus
|
||||
|
||||
@@ -9,15 +9,6 @@ export interface ScrollData {
|
||||
}
|
||||
|
||||
export function getScrollData(componentEl: HTMLElement, contentEl: HTMLElement, keyboardHeight: number): ScrollData {
|
||||
if (!contentEl) {
|
||||
return {
|
||||
scrollAmount: 0,
|
||||
scrollPadding: 0,
|
||||
scrollDuration: 0,
|
||||
inputSafeY: 0,
|
||||
};
|
||||
}
|
||||
|
||||
const itemEl = componentEl.closest('ion-item,[ion-item]') as HTMLElement || componentEl;
|
||||
return calcScrollData(
|
||||
itemEl.getBoundingClientRect(),
|
||||
|
||||
@@ -26,8 +26,8 @@ function setScrollPadding(input: HTMLElement, keyboardHeight: number) {
|
||||
if (input.parentElement && input.parentElement.tagName === 'ION-INPUT') {
|
||||
return;
|
||||
}
|
||||
const el = input.closest('ion-content') as HTMLElement;
|
||||
if (!el) {
|
||||
const el = input.closest('ion-content');
|
||||
if (el === null) {
|
||||
return;
|
||||
}
|
||||
const timer = (el as any)[PADDING_TIMER_KEY];
|
||||
|
||||
@@ -32,12 +32,12 @@ export function startInputShims(
|
||||
return;
|
||||
}
|
||||
|
||||
if (HIDE_CARET && scrollEl && hideCaret && !hideCaretMap.has(componentEl)) {
|
||||
if (HIDE_CARET && !!scrollEl && hideCaret && !hideCaretMap.has(componentEl)) {
|
||||
const rmFn = enableHideCaretOnScroll(componentEl, inputEl, scrollEl);
|
||||
hideCaretMap.set(componentEl, rmFn);
|
||||
}
|
||||
|
||||
if (SCROLL_ASSIST && scrollEl && scrollAssist && !scrollAssistMap.has(componentEl)) {
|
||||
if (SCROLL_ASSIST && !!scrollEl && scrollAssist && !scrollAssistMap.has(componentEl)) {
|
||||
const rmFn = enableScrollAssist(componentEl, inputEl, scrollEl, keyboardHeight);
|
||||
scrollAssistMap.set(componentEl, rmFn);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user