Apply strictNullChecks
to src/resizer/*
(#10378)
This commit is contained in:
parent
37d218eb61
commit
31a959efe9
3 changed files with 16 additions and 8 deletions
|
@ -21,7 +21,7 @@ import Sizer from "../sizer";
|
|||
|
||||
export interface ICollapseConfig extends IConfig {
|
||||
toggleSize: number;
|
||||
onCollapsed?(collapsed: boolean, id: string, element: HTMLElement): void;
|
||||
onCollapsed?(collapsed: boolean, id: string | null, element: HTMLElement): void;
|
||||
isItemCollapsed(element: HTMLElement): boolean;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ export default class CollapseDistributor extends FixedDistributor<ICollapseConfi
|
|||
return new CollapseItem(resizeHandle, resizer, sizer, container);
|
||||
}
|
||||
|
||||
private readonly toggleSize: number;
|
||||
private readonly toggleSize: number | undefined;
|
||||
private isCollapsed: boolean;
|
||||
|
||||
public constructor(item: CollapseItem) {
|
||||
|
@ -55,7 +55,7 @@ export default class CollapseDistributor extends FixedDistributor<ICollapseConfi
|
|||
}
|
||||
|
||||
public resize(newSize: number): void {
|
||||
const isCollapsedSize = newSize < this.toggleSize;
|
||||
const isCollapsedSize = !!this.toggleSize && newSize < this.toggleSize;
|
||||
if (isCollapsedSize !== this.isCollapsed) {
|
||||
this.isCollapsed = isCollapsedSize;
|
||||
this.item.notifyCollapsed(isCollapsedSize);
|
||||
|
|
|
@ -21,9 +21,9 @@ import { IConfig } from "../resizer";
|
|||
class PercentageSizer extends Sizer {
|
||||
public start(item: HTMLElement): void {
|
||||
if (this.vertical) {
|
||||
item.style.minHeight = null;
|
||||
item.style.minHeight = "";
|
||||
} else {
|
||||
item.style.minWidth = null;
|
||||
item.style.minWidth = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,14 +44,16 @@ export default class ResizeItem<C extends IConfig = IConfig> {
|
|||
|
||||
private advance(forwards: boolean): ResizeItem | undefined {
|
||||
// opposite direction from fromResizeHandle to get back to handle
|
||||
let handle = this.reverse ? this.domNode.previousElementSibling : this.domNode.nextElementSibling;
|
||||
let handle: Element | null | undefined = this.reverse
|
||||
? this.domNode.previousElementSibling
|
||||
: this.domNode.nextElementSibling;
|
||||
const moveNext = forwards !== this.reverse; // xor
|
||||
// iterate at least once to avoid infinite loop
|
||||
do {
|
||||
if (moveNext) {
|
||||
handle = handle.nextElementSibling;
|
||||
handle = handle?.nextElementSibling;
|
||||
} else {
|
||||
handle = handle.previousElementSibling;
|
||||
handle = handle?.previousElementSibling;
|
||||
}
|
||||
} while (handle && !this.resizer.isResizeHandle(<HTMLElement>handle));
|
||||
|
||||
|
@ -105,6 +107,9 @@ export default class ResizeItem<C extends IConfig = IConfig> {
|
|||
}
|
||||
|
||||
public first(): ResizeItem | undefined {
|
||||
if (!this.domNode.parentElement?.children) {
|
||||
return;
|
||||
}
|
||||
const firstHandle = Array.from(this.domNode.parentElement.children).find((el) => {
|
||||
return this.resizer.isResizeHandle(<HTMLElement>el);
|
||||
});
|
||||
|
@ -114,6 +119,9 @@ export default class ResizeItem<C extends IConfig = IConfig> {
|
|||
}
|
||||
|
||||
public last(): ResizeItem | undefined {
|
||||
if (!this.domNode.parentElement?.children) {
|
||||
return;
|
||||
}
|
||||
const lastHandle = Array.from(this.domNode.parentElement.children)
|
||||
.reverse()
|
||||
.find((el) => {
|
||||
|
|
Loading…
Reference in a new issue