@salesforcedevs/dx-components 1.18.9-rnb-scroll → 1.18.9-rnb-scroll1
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
|
@@ -25,8 +25,11 @@
|
|
|
25
25
|
margin-bottom: var(--dx-g-spacing-md);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
.toc-content-header {
|
|
29
|
+
width: 100%;
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
.toc-content-header[show-shadow="true"] {
|
|
29
|
-
width: 132px;
|
|
30
33
|
box-shadow: 0 4px 4px -2px var(--dx-g-gray-90);
|
|
31
34
|
}
|
|
32
35
|
|
|
@@ -37,7 +40,8 @@
|
|
|
37
40
|
.toc-items {
|
|
38
41
|
max-height: calc(100vh - 200px);
|
|
39
42
|
overflow-y: auto;
|
|
40
|
-
padding-bottom:
|
|
43
|
+
padding-bottom: 100px;
|
|
44
|
+
padding-right: 10px;
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
.dx-text-display-8 {
|
|
@@ -3,12 +3,11 @@ import cx from "classnames";
|
|
|
3
3
|
import { ContentElement } from "typings/custom";
|
|
4
4
|
import { toJson } from "dxUtils/normalizers";
|
|
5
5
|
import { track as sendGtm } from "dxUtils/analytics";
|
|
6
|
-
import {
|
|
6
|
+
import { handleScroll } from 'dxUtils/handleScroll';
|
|
7
7
|
|
|
8
8
|
export default class Toc extends LightningElement {
|
|
9
9
|
showBoxShadow: boolean = false;
|
|
10
|
-
|
|
11
|
-
handleScroll: (e: any) => void = () => {};
|
|
10
|
+
handleScroll = handleScroll.bind(this);
|
|
12
11
|
|
|
13
12
|
@api header!: string;
|
|
14
13
|
|
|
@@ -43,10 +42,6 @@ export default class Toc extends LightningElement {
|
|
|
43
42
|
|
|
44
43
|
@track _options!: Array<ContentElement>;
|
|
45
44
|
|
|
46
|
-
connectedCallback() {
|
|
47
|
-
this.handleScroll = SidebarBase.prototype.handleScroll.bind(this);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
45
|
private onClick(e: Event) {
|
|
51
46
|
const target = e.currentTarget as HTMLElement;
|
|
52
47
|
const id = target.getAttribute("contentid");
|
|
@@ -2,12 +2,14 @@ import { LightningElement, api } from "lwc";
|
|
|
2
2
|
import type { OptionWithLink } from "typings/custom";
|
|
3
3
|
import { toJson } from "dxUtils/normalizers";
|
|
4
4
|
import { Brand, DevCenterConfig } from "typings/custom";
|
|
5
|
+
import { handleScroll } from 'dxUtils/handleScroll';
|
|
5
6
|
|
|
6
7
|
export const HEIGHT_OF_SIDEBAR_ITEM = 32;
|
|
7
8
|
export const WAIT_TIME_BEFORE_SCROLL_IN_MS = 500;
|
|
8
9
|
|
|
9
10
|
export class SidebarBase extends LightningElement {
|
|
10
11
|
_sidebarContent: HTMLElement | null = null;
|
|
12
|
+
handleScroll = handleScroll.bind(this);
|
|
11
13
|
|
|
12
14
|
selectedElement: HTMLElement | null = null;
|
|
13
15
|
timerId: ReturnType<typeof setTimeout> | null = null;
|
|
@@ -16,7 +18,6 @@ export class SidebarBase extends LightningElement {
|
|
|
16
18
|
expanded: boolean = true;
|
|
17
19
|
_value?: string = undefined;
|
|
18
20
|
showBoxShadow: boolean = false;
|
|
19
|
-
private scrolling: boolean = false;
|
|
20
21
|
_devCenter!: DevCenterConfig;
|
|
21
22
|
|
|
22
23
|
@api langValuePath: string = "id";
|
|
@@ -61,29 +62,6 @@ export class SidebarBase extends LightningElement {
|
|
|
61
62
|
return this._sidebarContent;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
/**
|
|
65
|
-
* This method is to handle the scroll event for LNB and show box shadow
|
|
66
|
-
* @param scrollEvent
|
|
67
|
-
*/
|
|
68
|
-
handleScroll(scrollEvent: any) {
|
|
69
|
-
const lnb = scrollEvent.target;
|
|
70
|
-
|
|
71
|
-
if (!this.scrolling) {
|
|
72
|
-
this.scrolling = true;
|
|
73
|
-
// Set a timeout to handle scroll event after a delay
|
|
74
|
-
setTimeout(() => {
|
|
75
|
-
// Check if lnb is scrolled
|
|
76
|
-
if (lnb.scrollTop > 0 && lnb.scrollHeight > lnb.clientHeight) {
|
|
77
|
-
this.showBoxShadow = true;
|
|
78
|
-
} else {
|
|
79
|
-
this.showBoxShadow = false;
|
|
80
|
-
}
|
|
81
|
-
// Reset scrolling back to false after handling the scroll
|
|
82
|
-
this.scrolling = false;
|
|
83
|
-
}, 200);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
65
|
renderedCallback(): void {
|
|
88
66
|
/**
|
|
89
67
|
* Implementing debouncing kind of logic here to scroll to selected element once tree rendering is done
|