gatsby-core-theme 30.0.41 → 30.0.43
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,18 @@
|
|
|
1
|
+
## [30.0.43](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v30.0.42...v30.0.43) (2024-01-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* arranged function for scroll to top ([8a7cba2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/8a7cba2feef8b3d55803baa1a3db5dcbb069bd96))
|
|
7
|
+
|
|
8
|
+
## [30.0.42](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v30.0.41...v30.0.42) (2024-01-03)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* fixed failing test ([bf76bf1](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/bf76bf17ed8dd64de671b6f75d300dddba4a3473))
|
|
14
|
+
* scroll to top to stick to footer ([70343a9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/70343a95bbf2dcc16fb0071e56939018d72e55c7))
|
|
15
|
+
|
|
1
16
|
## [30.0.41](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v30.0.40...v30.0.41) (2024-01-03)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
-
import React, { useContext, useEffect, useState } from 'react';
|
|
2
|
+
import React, { useContext, useEffect, useState, useRef } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import isSticky from '~hooks/stickyOnScroll';
|
|
5
5
|
import { Context } from '~context/MainProvider';
|
|
@@ -10,6 +10,7 @@ const ScrollToTop = ({ scrollTo = '0', offsetTop = 400, hideOnScrollDown = false
|
|
|
10
10
|
const [show, setShow] = useState(false);
|
|
11
11
|
let scrollY = typeof window !== 'undefined' && (window?.scrollY || 0);
|
|
12
12
|
const showScroll = isSticky(offsetTop);
|
|
13
|
+
const scrollToTopBtn = useRef();
|
|
13
14
|
|
|
14
15
|
const scrollTop = () => {
|
|
15
16
|
window.scrollTo({ top: scrollTo, behavior: 'smooth' });
|
|
@@ -21,6 +22,15 @@ const ScrollToTop = ({ scrollTo = '0', offsetTop = 400, hideOnScrollDown = false
|
|
|
21
22
|
} else {
|
|
22
23
|
setShow(true);
|
|
23
24
|
}
|
|
25
|
+
const footerElementRect =
|
|
26
|
+
document.querySelector('footer') && document.querySelector('footer').getBoundingClientRect();
|
|
27
|
+
if (footerElementRect) {
|
|
28
|
+
if (footerElementRect.y < window.innerHeight) {
|
|
29
|
+
scrollToTopBtn.current.style.bottom = `${window.innerHeight - footerElementRect.y - 30}px`;
|
|
30
|
+
} else {
|
|
31
|
+
scrollToTopBtn.current.style.bottom = '0px';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
24
34
|
|
|
25
35
|
scrollY = window.scrollY;
|
|
26
36
|
};
|
|
@@ -42,6 +52,7 @@ const ScrollToTop = ({ scrollTo = '0', offsetTop = 400, hideOnScrollDown = false
|
|
|
42
52
|
type="button"
|
|
43
53
|
aria-label="Scroll to top"
|
|
44
54
|
onClick={(e) => scrollTop(e)}
|
|
55
|
+
ref={scrollToTopBtn}
|
|
45
56
|
className={`${styles.scrollToTop || ''} ${cookieAccepted && (styles.cookieAccepted || '')} ${
|
|
46
57
|
!bannerIsActive && (styles.closedBanner || '')
|
|
47
58
|
} ${!show && hideOnScrollDown && (styles?.showScrollToTopButton || '')}`}
|