Skip to content

Commit

Permalink
feat: trigger event on window when tab is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
dkjensen committed May 11, 2022
1 parent 8ab0e8b commit 13b49ce
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/tabs/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,20 @@

tabLabels.forEach(label => {
label.classList.remove('active');
label.setAttribute( 'aria-selected', 'false' );
label.setAttribute('aria-selected', 'false');
});

activeIndex = parseInt(id);

const currentTabLabel = tabLabelsContainer.querySelector('[tabid="' + activeIndex + '"]');
currentTabLabel.classList.add('active');
currentTabLabel.setAttribute( 'aria-selected', 'true' );
currentTabLabel.setAttribute('aria-selected', 'true');

tabsContainer.querySelector('[tabid="' + activeIndex + '"]').style.display = 'block';

const event = new Event('tabChanged');

window.dispatchEvent(event);
};

const determineOrientation = (event) => {
Expand Down Expand Up @@ -111,8 +115,6 @@
tabLabels[x].addEventListener('focus', focusEventHandler);
}

console.log( direction[pressed] );

if (direction[pressed]) {
var desiredIndex = activeIndex + direction[pressed];

Expand Down

0 comments on commit 13b49ce

Please sign in to comment.