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

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-alpha4",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -219,7 +219,7 @@ export default class ContentLayout extends LightningElement {
219
219
  this.template.querySelector("[name=doc-phase]")! as any
220
220
  ).assignedElements()[0] as HTMLSlotElement;
221
221
 
222
- if(!docPhaseEl) {
222
+ if (!docPhaseEl) {
223
223
  docPhaseEl = (
224
224
  this.template.querySelector("[name=version-banner]")! as any
225
225
  ).assignedElements()[0] as HTMLSlotElement;
@@ -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;
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,27 @@ 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
+ 40
265
+ }px`
266
+ : `${totalHeaderHeight + 40}px`;
267
+ });
268
+
269
+ // Adjusting the right nav bar on scroll.
270
+ if (rightNavBarEl) {
271
+ rightNavBarEl.style.top = docPhaseEl
272
+ ? `${
273
+ totalHeaderHeight +
274
+ docPhaseEl.getBoundingClientRect().height
275
+ }px`
276
+ : `${totalHeaderHeight}px`;
277
+ }
278
+
250
279
  // 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
280
  if (docPhaseEl) {
252
281
  docPhaseEl.style.setProperty(
@@ -259,31 +288,6 @@ export default class ContentLayout extends LightningElement {
259
288
  : globalNavHeight + docHeaderHeight
260
289
  }px`
261
290
  );
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
291
  }
288
292
  });
289
293
  };