@salesforcedevs/docs-components 1.3.130-alpha.0 → 1.3.130-alpha.1
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
|
@@ -369,15 +369,52 @@ export default class ContentLayout extends LightningElement {
|
|
|
369
369
|
let { hash } = window.location;
|
|
370
370
|
if (hash) {
|
|
371
371
|
hash = hash.substr(1);
|
|
372
|
+
|
|
373
|
+
const docHeaderEl = document.querySelector(
|
|
374
|
+
".sticky-doc-header"
|
|
375
|
+
) as HTMLElement;
|
|
376
|
+
const globalNavEl = document.querySelector(
|
|
377
|
+
"hgf-c360nav"
|
|
378
|
+
) as HTMLElement;
|
|
379
|
+
const contextNavEl = document.querySelector(
|
|
380
|
+
"hgf-c360contextnav"
|
|
381
|
+
) as HTMLElement;
|
|
382
|
+
|
|
383
|
+
const headerHeight =
|
|
384
|
+
docHeaderEl.offsetHeight +
|
|
385
|
+
globalNavEl.offsetHeight +
|
|
386
|
+
contextNavEl.offsetHeight;
|
|
387
|
+
|
|
388
|
+
const docPhaseEl = this.template
|
|
389
|
+
.querySelector("[name=doc-phase]")!
|
|
390
|
+
.assignedElements()[0] as HTMLSlotElement;
|
|
391
|
+
|
|
392
|
+
const offset = docPhaseEl
|
|
393
|
+
? headerHeight + docPhaseEl.offsetHeight
|
|
394
|
+
: headerHeight;
|
|
395
|
+
|
|
372
396
|
for (const headingElement of headingElements) {
|
|
373
397
|
if (headingElement.getAttribute("id") === hash) {
|
|
374
|
-
|
|
398
|
+
this.scrollIntoViewWithOffset(headingElement, offset);
|
|
375
399
|
break;
|
|
376
400
|
}
|
|
377
401
|
}
|
|
378
402
|
}
|
|
379
403
|
}
|
|
380
404
|
|
|
405
|
+
private scrollIntoViewWithOffset(
|
|
406
|
+
headingElement: HTMLElement,
|
|
407
|
+
offset: number
|
|
408
|
+
) {
|
|
409
|
+
window.scrollTo({
|
|
410
|
+
behavior: "auto",
|
|
411
|
+
top:
|
|
412
|
+
headingElement.getBoundingClientRect().top -
|
|
413
|
+
document.body.getBoundingClientRect().top -
|
|
414
|
+
offset
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
|
|
381
418
|
private calculateActualSection(): void {
|
|
382
419
|
const currentScrollPosition = document.documentElement.scrollTop;
|
|
383
420
|
const id = Object.keys(this.anchoredElements).find(
|