wunderbaum 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/wunderbaum.ts CHANGED
@@ -105,7 +105,7 @@ export class Wunderbaum {
105
105
  public readonly data: { [key: string]: any } = {};
106
106
 
107
107
  protected readonly _updateViewportThrottled: (...args: any) => void;
108
- protected extensionList: WunderbaumExtension[] = [];
108
+ protected extensionList: WunderbaumExtension<any>[] = [];
109
109
  protected extensions: ExtensionsDict = {};
110
110
 
111
111
  /** Merged options from constructor args and tree- and extension defaults. */
@@ -436,7 +436,9 @@ export class Wunderbaum {
436
436
  }
437
437
 
438
438
  if (info.region === NodeRegion.expander) {
439
- node.setExpanded(!node.isExpanded());
439
+ node.setExpanded(!node.isExpanded(), {
440
+ scrollIntoView: options.scrollIntoViewOnExpandClick !== false,
441
+ });
440
442
  } else if (info.region === NodeRegion.checkbox) {
441
443
  node.toggleSelected();
442
444
  }
@@ -596,7 +598,7 @@ export class Wunderbaum {
596
598
  }
597
599
 
598
600
  /** @internal */
599
- protected _registerExtension(extension: WunderbaumExtension): void {
601
+ protected _registerExtension(extension: WunderbaumExtension<any>): void {
600
602
  this.extensionList.push(extension);
601
603
  this.extensions[extension.id] = extension;
602
604
  // this.extensionMap.set(extension.id, extension);
@@ -647,7 +649,10 @@ export class Wunderbaum {
647
649
  }
648
650
 
649
651
  /** Call all hook methods of all registered extensions.*/
650
- protected _callHook(hook: keyof WunderbaumExtension, data: any = {}): any {
652
+ protected _callHook(
653
+ hook: keyof WunderbaumExtension<any>,
654
+ data: any = {}
655
+ ): any {
651
656
  let res;
652
657
  let d = util.extend(
653
658
  {},
@@ -2086,19 +2091,17 @@ export class Wunderbaum {
2086
2091
  // this.log("_updateViewportImmediately(): scroll only.");
2087
2092
  } else {
2088
2093
  this.log("_updateViewportImmediately():", pending);
2089
- let height = this.listContainerElement.clientHeight;
2090
- // We cannot get the height for absolute positioned parent, so look at first col
2091
- // let headerHeight = this.headerElement.clientHeight
2092
- // let headerHeight = this.headerElement.children[0].children[0].clientHeight;
2093
- // const headerHeight = this.options.headerHeightPx;
2094
- const headerHeight = this.headerElement.clientHeight; // May be 0
2095
- const wantHeight =
2096
- this.element.clientHeight - headerHeight - FIX_ADJUST_HEIGHT;
2097
-
2098
- if (Math.abs(height - wantHeight) > 1.0) {
2099
- // this.log("resize", height, wantHeight);
2100
- this.listContainerElement.style.height = wantHeight + "px";
2101
- height = wantHeight;
2094
+ if (this.options.adjustHeight !== false) {
2095
+ let height = this.listContainerElement.clientHeight;
2096
+ const headerHeight = this.headerElement.clientHeight; // May be 0
2097
+ const wantHeight =
2098
+ this.element.clientHeight - headerHeight - FIX_ADJUST_HEIGHT;
2099
+
2100
+ if (Math.abs(height - wantHeight) > 1.0) {
2101
+ // this.log("resize", height, wantHeight);
2102
+ this.listContainerElement.style.height = wantHeight + "px";
2103
+ height = wantHeight;
2104
+ }
2102
2105
  }
2103
2106
  // console.profile(`_updateViewportImmediately()`)
2104
2107