@salesforcedevs/dx-components 1.18.9-rnb-scroll1 → 1.18.9-rnb-scroll2
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
|
@@ -3,11 +3,12 @@ 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 { handleScroll } from 'dxUtils/handleScroll';
|
|
6
|
+
import { handleScroll, makeListContainerScrollable } from 'dxUtils/handleScroll';
|
|
7
7
|
|
|
8
8
|
export default class Toc extends LightningElement {
|
|
9
9
|
showBoxShadow: boolean = false;
|
|
10
10
|
handleScroll = handleScroll.bind(this);
|
|
11
|
+
makeListContainerScrollable = makeListContainerScrollable.bind(this);
|
|
11
12
|
|
|
12
13
|
@api header!: string;
|
|
13
14
|
|
|
@@ -42,6 +43,10 @@ export default class Toc extends LightningElement {
|
|
|
42
43
|
|
|
43
44
|
@track _options!: Array<ContentElement>;
|
|
44
45
|
|
|
46
|
+
renderedCallback() {
|
|
47
|
+
this.makeListContainerScrollable(".toc-items");
|
|
48
|
+
}
|
|
49
|
+
|
|
45
50
|
private onClick(e: Event) {
|
|
46
51
|
const target = e.currentTarget as HTMLElement;
|
|
47
52
|
const id = target.getAttribute("contentid");
|
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
export function handleScroll(this: any, scrollEvent: any) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
const list = scrollEvent.target;
|
|
3
|
+
|
|
4
|
+
setTimeout(() => {
|
|
5
|
+
this.showBoxShadow = (list.scrollTop > 0 && list.scrollHeight > list.clientHeight);
|
|
6
|
+
}, 200);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function makeListContainerScrollable(this: any, classname: string) {
|
|
10
|
+
const rnbList = this.template.querySelector(classname);
|
|
11
|
+
|
|
12
|
+
if(rnbList) {
|
|
13
|
+
const rect = rnbList?.getBoundingClientRect();
|
|
14
|
+
const distanceFromTop = rect?.top || 0;
|
|
15
|
+
const viewportHeight = window.innerHeight;
|
|
16
|
+
const maxHeight = viewportHeight - distanceFromTop;
|
|
17
|
+
|
|
18
|
+
rnbList.style.maxHeight = `${maxHeight}px`;
|
|
19
|
+
}
|
|
7
20
|
}
|