@salesforcedevs/dx-components 0.43.3-tree-selected-scroll-3 → 0.43.3-tree-selected-scroll-4
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/package.json
CHANGED
|
@@ -4,9 +4,6 @@ export const HEIGHT_OF_SIDEBAR_ITEM = 32;
|
|
|
4
4
|
|
|
5
5
|
export class SidebarBase extends LightningElement {
|
|
6
6
|
_sidebarContent: HTMLElement | null = null;
|
|
7
|
-
private selectedTreeItem: HTMLElement | null = null;
|
|
8
|
-
private isSidebarRendered = false;
|
|
9
|
-
|
|
10
7
|
get sidebarContent() {
|
|
11
8
|
if (!this._sidebarContent) {
|
|
12
9
|
this._sidebarContent = this.template.querySelector(
|
|
@@ -16,19 +13,13 @@ export class SidebarBase extends LightningElement {
|
|
|
16
13
|
return this._sidebarContent;
|
|
17
14
|
}
|
|
18
15
|
|
|
16
|
+
/*Scroll to selected tree item */
|
|
19
17
|
private onSelectedItemRendered(event: CustomEvent) {
|
|
20
18
|
event.stopPropagation();
|
|
21
|
-
|
|
22
|
-
if (this.
|
|
23
|
-
this.scrollToSelectedItem();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/*Scroll to selected tree item */
|
|
28
|
-
private scrollToSelectedItem(): void {
|
|
29
|
-
if (this.selectedTreeItem && this.sidebarContent) {
|
|
19
|
+
const selectedTreeItem = event.detail.element;
|
|
20
|
+
if (selectedTreeItem && this.sidebarContent) {
|
|
30
21
|
const scrollHeight: number =
|
|
31
|
-
|
|
22
|
+
selectedTreeItem.getBoundingClientRect().bottom -
|
|
32
23
|
this.sidebarContent.getBoundingClientRect().bottom + // We need to remove parent bottom
|
|
33
24
|
HEIGHT_OF_SIDEBAR_ITEM * 3; // add height of 3 more items so that user can see at least three more items after selected item
|
|
34
25
|
this.sidebarContent.scrollTo({
|
|
@@ -36,11 +27,5 @@ export class SidebarBase extends LightningElement {
|
|
|
36
27
|
behavior: "smooth"
|
|
37
28
|
});
|
|
38
29
|
}
|
|
39
|
-
this.selectedTreeItem = null;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
renderedCallback(): void {
|
|
43
|
-
this.isSidebarRendered = true;
|
|
44
|
-
this.scrollToSelectedItem();
|
|
45
30
|
}
|
|
46
31
|
}
|
|
@@ -81,10 +81,6 @@ export default class Sidebar extends SidebarBase {
|
|
|
81
81
|
this.matchMedia.addEventListener("change", this.onMediaChange);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
renderedCallback(): void {
|
|
85
|
-
super.renderedCallback();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
84
|
disconnectedCallback() {
|
|
89
85
|
this.matchMedia.removeEventListener("change", this.onMediaChange);
|
|
90
86
|
}
|