Skip to content

Commit 795f254

Browse files
committed
fix: sdk section active menu
1 parent b1641a3 commit 795f254

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/components/homepage/SDKsSection.jsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,19 @@ export default function SDKsSection() {
4141
const [visibleSection, setVisibleSection] = useState('Web');
4242

4343
React.useEffect(() => {
44-
const observer = new IntersectionObserver((entries) => {
45-
for (const entry of entries) {
46-
const section = entry.target.getAttribute('data-section');
44+
const observer = new IntersectionObserver(
45+
(entries) => {
46+
for (const entry of entries) {
47+
const section = entry.target.getAttribute('data-section');
4748

48-
if (entry.isIntersecting) {
49-
entry.target.classList.add('intersected');
50-
setVisibleSection(section);
49+
if (entry.isIntersecting) {
50+
entry.target.classList.add('intersected');
51+
setVisibleSection(section);
52+
}
5153
}
52-
}
53-
});
54+
},
55+
{ rootMargin: '-50% 0% -50% 0%' }
56+
);
5457

5558
const elements = document.querySelectorAll('.sdk-section');
5659
for (const el of elements) {

0 commit comments

Comments
 (0)