@salesforcedevs/docs-components 1.3.300-scroll-alpha2 → 1.3.300-scroll-alpha3

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/docs-components",
3
- "version": "1.3.300-scroll-alpha2",
3
+ "version": "1.3.300-scroll-alpha3",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -237,6 +237,14 @@ export default class ContentLayout extends LightningElement {
237
237
  (globalNavEl.getBoundingClientRect().height !== 72 ? 0 : 72) +
238
238
  contextNavEl.getBoundingClientRect().height;
239
239
  const docHeaderHeight = docHeaderEl.getBoundingClientRect().height;
240
+ const totalHeaderHeight = globalNavHeight + docHeaderHeight + 40;
241
+
242
+ // Selecting the doc section heading and RNB here.
243
+ const docHeadingEls = Array.from(
244
+ document.querySelectorAll("doc-heading")
245
+ );
246
+ const rightNavBarEl = this.template.querySelector(".right-nav-bar");
247
+
240
248
  sidebarEl.style.setProperty(
241
249
  "--dx-c-content-sidebar-sticky-top",
242
250
  `${globalNavHeight + docHeaderHeight}px`
@@ -247,6 +255,26 @@ export default class ContentLayout extends LightningElement {
247
255
  `${globalNavHeight}px`
248
256
  );
249
257
 
258
+ // Adjusting the doc section heading on scroll.
259
+ docHeadingEls.forEach((docHeadingEl) => {
260
+ (docHeadingEl as any).style.scrollMarginTop = docPhaseEl
261
+ ? `${
262
+ totalHeaderHeight +
263
+ docPhaseEl.getBoundingClientRect().height
264
+ }px`
265
+ : `${totalHeaderHeight}px`;
266
+ });
267
+
268
+ // Adjusting the right nav bar on scroll.
269
+ if (rightNavBarEl) {
270
+ rightNavBarEl.style.top = docPhaseEl
271
+ ? `${
272
+ totalHeaderHeight +
273
+ docPhaseEl.getBoundingClientRect().height
274
+ }px`
275
+ : `${totalHeaderHeight}px`;
276
+ }
277
+
250
278
  // If doc phase element exists, we need to account for its sticky position. Mobile should include the sidebar height (since it becomes sticky aswell).
251
279
  if (docPhaseEl) {
252
280
  docPhaseEl.style.setProperty(
@@ -259,31 +287,6 @@ export default class ContentLayout extends LightningElement {
259
287
  : globalNavHeight + docHeaderHeight
260
288
  }px`
261
289
  );
262
-
263
- // Adjust scroll margin for doc headings when doc phase is present
264
- const docHeadingEls = Array.from(
265
- document.querySelectorAll("doc-heading")
266
- );
267
- docHeadingEls.forEach((docHeadingEl) => {
268
- (docHeadingEl as any).style.scrollMarginTop = `${
269
- globalNavHeight +
270
- docHeaderHeight +
271
- docPhaseEl.getBoundingClientRect().height +
272
- 40
273
- }px`;
274
- });
275
-
276
- // Adjust right nav bar position when doc phase is present
277
- const rightNavBarEl =
278
- this.template.querySelector(".right-nav-bar");
279
-
280
- if (rightNavBarEl) {
281
- rightNavBarEl.style.top = `${
282
- globalNavHeight +
283
- docHeaderHeight +
284
- docPhaseEl.getBoundingClientRect().height
285
- }px`;
286
- }
287
290
  }
288
291
  });
289
292
  };