Skip to content

Commit

Permalink
fix: sdk section active menu
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhavshn committed Nov 23, 2022
1 parent b1641a3 commit 795f254
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/components/homepage/SDKsSection.jsx
Expand Up @@ -41,16 +41,19 @@ export default function SDKsSection() {
const [visibleSection, setVisibleSection] = useState('Web');

React.useEffect(() => {
const observer = new IntersectionObserver((entries) => {
for (const entry of entries) {
const section = entry.target.getAttribute('data-section');
const observer = new IntersectionObserver(
(entries) => {
for (const entry of entries) {
const section = entry.target.getAttribute('data-section');

if (entry.isIntersecting) {
entry.target.classList.add('intersected');
setVisibleSection(section);
if (entry.isIntersecting) {
entry.target.classList.add('intersected');
setVisibleSection(section);
}
}
}
});
},
{ rootMargin: '-50% 0% -50% 0%' }
);

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

0 comments on commit 795f254

Please sign in to comment.