gatsby-core-theme 9.0.2 → 9.0.3
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [9.0.3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v9.0.2...v9.0.3) (2022-08-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* add height of anchor like props ([98dfdae](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/98dfdaef2e1e10a6fb8165c9a2cd943fe7eaacec))
|
|
7
|
+
|
|
1
8
|
## [9.0.2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v9.0.1...v9.0.2) (2022-08-02)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -17,6 +17,8 @@ function Anchor({
|
|
|
17
17
|
isFixed = true,
|
|
18
18
|
icon = null,
|
|
19
19
|
showTitle = true,
|
|
20
|
+
heightOfAnchor = 60,
|
|
21
|
+
offset = 10,
|
|
20
22
|
}) {
|
|
21
23
|
const [offsetTop, setOffsetTop] = useState(null);
|
|
22
24
|
const itemsRef = useRef([]);
|
|
@@ -38,7 +40,7 @@ function Anchor({
|
|
|
38
40
|
if (targetEl) {
|
|
39
41
|
const offsetPosition = targetEl.offsetTop - headerOffset;
|
|
40
42
|
window.scrollTo({
|
|
41
|
-
top: isFixed ? offsetPosition -
|
|
43
|
+
top: isFixed ? offsetPosition - heightOfAnchor : offsetPosition,
|
|
42
44
|
});
|
|
43
45
|
}
|
|
44
46
|
};
|
|
@@ -47,7 +49,7 @@ function Anchor({
|
|
|
47
49
|
// get element in viewport
|
|
48
50
|
const currentAnchor = anchorList?.map((el) => {
|
|
49
51
|
const element = document.getElementById(el.id);
|
|
50
|
-
if (element?.offsetTop - headerOffset -
|
|
52
|
+
if (element?.offsetTop - headerOffset - heightOfAnchor - offset <= window.scrollY) {
|
|
51
53
|
return element;
|
|
52
54
|
}
|
|
53
55
|
return null;
|
|
@@ -139,6 +141,8 @@ Anchor.propTypes = {
|
|
|
139
141
|
isFixed: PropTypes.bool,
|
|
140
142
|
icon: PropTypes.element,
|
|
141
143
|
showTitle: PropTypes.string,
|
|
144
|
+
heightOfAnchor: PropTypes.number,
|
|
145
|
+
offset: PropTypes.number,
|
|
142
146
|
};
|
|
143
147
|
|
|
144
148
|
export default Anchor;
|