@salesforcedevs/docs-components 1.34.5-scroll-1 → 1.34.5-scroll-2

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.34.5-scroll-1",
3
+ "version": "1.34.5-scroll-2",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -517,25 +517,25 @@ export default class ContentLayout extends LightningElement {
517
517
  this.didScrollToSelectedHash = true;
518
518
  return;
519
519
  }
520
- if (this.hasPendingCodeBlocks()) {
521
- this.hashScrollWaitStart ??= Date.now();
522
- if (
523
- Date.now() - this.hashScrollWaitStart <
524
- MAX_HASH_SCROLL_WAIT_TIME
525
- ) {
526
- clearTimeout(this.hashScrollTimerId);
527
- this.hashScrollTimerId = setTimeout(
528
- () => this.tryScrollToHash(this.getHeadingElements()),
529
- HASH_SCROLL_DELAY
530
- );
531
- return;
532
- }
533
- }
534
- if (this.scrollToHash(headingElements)) {
520
+ this.hashScrollWaitStart ??= Date.now();
521
+ const waitExpired =
522
+ Date.now() - this.hashScrollWaitStart >= MAX_HASH_SCROLL_WAIT_TIME;
523
+ const scrolled =
524
+ (waitExpired || !this.hasPendingCodeBlocks()) &&
525
+ this.scrollToHash(headingElements);
526
+
527
+ if (scrolled || waitExpired) {
535
528
  this.didScrollToSelectedHash = true;
536
529
  this.hashScrollWaitStart = undefined;
537
530
  clearTimeout(this.hashScrollTimerId);
531
+ return;
538
532
  }
533
+
534
+ clearTimeout(this.hashScrollTimerId);
535
+ this.hashScrollTimerId = setTimeout(
536
+ () => this.tryScrollToHash(this.getHeadingElements()),
537
+ HASH_SCROLL_DELAY
538
+ );
539
539
  }
540
540
 
541
541
  protected hasPendingCodeBlocks(): boolean {