@apify/docs-theme 1.0.139 → 1.0.141

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": "@apify/docs-theme",
3
- "version": "1.0.139",
3
+ "version": "1.0.141",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "files": [
@@ -1609,3 +1609,8 @@ iframe[src*="youtube"] {
1609
1609
  height: auto;
1610
1610
  margin-bottom: 1.6rem;
1611
1611
  }
1612
+
1613
+ .redocusaurus div[data-section-id] span[id] {
1614
+ margin-top: -130px;
1615
+ position: absolute;
1616
+ }
@@ -32,3 +32,45 @@
32
32
  // load();
33
33
  // }
34
34
  // }, 500);
35
+
36
+ let lastKnownScrollHash = '';
37
+
38
+ // handles automatic scrolling of the API reference sidebar (redoc)
39
+ function scrollSidebarItemIntoView() {
40
+ const hash = window.location.hash.substring(1);
41
+
42
+ if (hash !== lastKnownScrollHash) {
43
+ const $li = document.querySelector(`li[data-item-id="${hash}"]`);
44
+
45
+ if (!$li) {
46
+ return;
47
+ }
48
+
49
+ // not visible, click on the parent <li> first
50
+ if (!$li.offsetParent) {
51
+ $li.parentElement?.parentElement?.click();
52
+ }
53
+
54
+ $li.scrollIntoView({
55
+ // smooth would be nice, but it's not working in some case
56
+ // behavior: 'smooth',
57
+ block: 'nearest',
58
+ inline: 'center',
59
+ });
60
+ lastKnownScrollHash = hash;
61
+ }
62
+ }
63
+
64
+ let ticking = false;
65
+
66
+ document.addEventListener('scroll', () => {
67
+ if (!ticking) {
68
+ // throttling based on current frame rate
69
+ window.requestAnimationFrame(() => {
70
+ scrollSidebarItemIntoView();
71
+ ticking = false;
72
+ });
73
+
74
+ ticking = true;
75
+ }
76
+ });