@salesforcedevs/docs-components 1.3.282-scroll-fix-alpha1 → 1.3.282-scroll-fix-alpha2

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.282-scroll-fix-alpha1",
3
+ "version": "1.3.282-scroll-fix-alpha2",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -385,7 +385,6 @@ mark {
385
385
  /* offset page jump link due to fixed header */
386
386
  [id] {
387
387
  scroll-margin-top: calc(
388
- var(--dx-g-global-header-height) + var(--dx-g-doc-header-height) +
389
- var(--dx-g-spacing-4xl) - var(--dx-g-spacing-xs)
388
+ var(--dx-g-global-header-height) + var(--dx-g-doc-header-height)
390
389
  );
391
390
  }
@@ -42,7 +42,9 @@ dx-toc {
42
42
 
43
43
  /* offset page jump link due to fixed header */
44
44
  ::slotted(doc-heading) {
45
- scroll-margin-top: calc(var(--dx-c-content-sidebar-sticky-top) + 30px);
45
+ scroll-margin-top: calc(
46
+ var(--dx-g-global-header-height) + var(--dx-g-doc-header-height)
47
+ );
46
48
  }
47
49
 
48
50
  .content {
@@ -231,20 +231,37 @@ export default class ContentLayout extends LightningElement {
231
231
  (globalNavEl.getBoundingClientRect().height !== 72 ? 0 : 72) +
232
232
  contextNavEl.getBoundingClientRect().height;
233
233
  const docHeaderHeight = docHeaderEl.getBoundingClientRect().height;
234
+ const totalHeaderHeight = globalNavHeight + docHeaderHeight;
235
+
236
+ const docHeadingEls = Array.from(
237
+ document.querySelectorAll("doc-heading")
238
+ );
239
+ const rightNavBarEl = this.template.querySelector(".right-nav-bar");
240
+
234
241
  sidebarEl.style.setProperty(
235
242
  "--dx-c-content-sidebar-sticky-top",
236
243
  `${globalNavHeight + docHeaderHeight}px`
237
244
  );
238
245
 
239
- docHeaderEl.style.setProperty(
240
- "--dx-g-global-header-height",
241
- `${globalNavHeight}px`
242
- );
243
-
244
- const rnbEl = this.template.querySelector(".right-nav-bar");
245
-
246
- if (rnbEl) {
247
- rnbEl.style.top = `${globalNavHeight + docHeaderHeight + 30}px`;
246
+ docHeadingEls.forEach((docHeadingEl) => {
247
+ (docHeadingEl as any).style.scrollMarginTop = docPhaseEl
248
+ ? `${
249
+ totalHeaderHeight +
250
+ docPhaseEl.getBoundingClientRect().height
251
+ }px`
252
+ : `${totalHeaderHeight + 30}px`;
253
+ });
254
+
255
+ if (rightNavBarEl) {
256
+ rightNavBarEl.style.setProperty(
257
+ "--dx-c-content-sidebar-sticky-top",
258
+ docPhaseEl
259
+ ? `${
260
+ totalHeaderHeight +
261
+ docPhaseEl.getBoundingClientRect().height
262
+ }px`
263
+ : `${totalHeaderHeight}px`
264
+ );
248
265
  }
249
266
 
250
267
  // If doc phase element exists, we need to account for its sticky position. Mobile should include the sidebar height (since it becomes sticky aswell).
@@ -259,30 +276,6 @@ export default class ContentLayout extends LightningElement {
259
276
  : globalNavHeight + docHeaderHeight
260
277
  }px`
261
278
  );
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
- }px`;
273
- });
274
-
275
- // Adjust right nav bar position when doc phase is present
276
- const rightNavBarEl =
277
- this.template.querySelector(".right-nav-bar");
278
-
279
- if (rightNavBarEl) {
280
- rightNavBarEl.style.top = `${
281
- globalNavHeight +
282
- docHeaderHeight +
283
- docPhaseEl.getBoundingClientRect().height
284
- }px`;
285
- }
286
279
  }
287
280
  });
288
281
  };