@salesforcedevs/dx-components 1.20.0-rnb-scroll-2 → 1.20.0-rnb-scroll-3

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "1.20.0-rnb-scroll-2",
3
+ "version": "1.20.0-rnb-scroll-3",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -6,7 +6,7 @@
6
6
  </div>
7
7
  <div
8
8
  class="toc-items"
9
- show-bottom-shadow={showBoxShadowBottom}
9
+ show-bottom-shadow={showBottomShadow}
10
10
  onscroll={handleScroll}
11
11
  >
12
12
  <template for:each={options} for:item="option">
@@ -6,12 +6,16 @@ import { track as sendGtm } from "dxUtils/analytics";
6
6
  import { handleScroll } from "dxUtils/handleScroll";
7
7
 
8
8
  export default class Toc extends LightningElement {
9
- showBoxShadow: boolean = false;
10
- showBoxShadowBottom: boolean = false;
9
+ // For showing shadow at the top
10
+ private showBoxShadow: boolean = false;
11
11
  private scrolling: boolean = false;
12
- private scrollToBottom: boolean = false;
12
+
13
13
  handleScroll = handleScroll.bind(this);
14
14
 
15
+ // For showing shadow at the bottom
16
+ private showBottomShadow: boolean = false;
17
+ private scrollingToTop: boolean = false;
18
+
15
19
  @api header!: string;
16
20
 
17
21
  @api
@@ -49,20 +53,26 @@ export default class Toc extends LightningElement {
49
53
  private showShadowAtBottom = (event: any) => {
50
54
  const list = event.target;
51
55
 
52
- if (!this.scrollToBottom) {
53
- this.scrollToBottom = true;
56
+ if (!this.scrollingToTop) {
57
+ this.scrollingToTop = true;
54
58
  // Set a timeout to handle scroll event after a delay
55
59
  setTimeout(() => {
56
60
  const isScrollable = list.scrollHeight > list.clientHeight;
57
61
  const isAtBottom =
58
62
  list.scrollTop + list.clientHeight >=
59
- list.scrollHeight - 75;
63
+ list.scrollHeight -
64
+ parseInt(
65
+ getComputedStyle(
66
+ this.template.host
67
+ ).getPropertyValue("--dx-c-toc-padding-bottom"),
68
+ 10
69
+ );
60
70
 
61
- this.showBoxShadowBottom = isScrollable && !isAtBottom;
71
+ this.showBottomShadow = isScrollable && !isAtBottom;
62
72
 
63
73
  // Reset scrolling back to false after handling the scroll
64
- this.scrollToBottom = false;
65
- }, 100);
74
+ this.scrollingToTop = false;
75
+ }, 200);
66
76
  }
67
77
  };
68
78