main.ts 765 B

123456789101112131415161718192021222324252627
  1. import '@webcomponents/custom-elements';
  2. import { initIcons } from './icons';
  3. import { TocHighlighter } from './toc-highlighter';
  4. // tslint:disable-next-line
  5. require('../styles/main.scss');
  6. initIcons();
  7. document.addEventListener('DOMContentLoaded', () => {
  8. const topBar = document.querySelector('.top-bar');
  9. if (topBar) {
  10. window.addEventListener('scroll', (e) => {
  11. if (window.scrollY === 0) {
  12. topBar.classList.remove('floating');
  13. } else {
  14. topBar.classList.add('floating');
  15. }
  16. });
  17. }
  18. const toc = document.querySelector('#TableOfContents');
  19. if (toc) {
  20. const tocHighlighter = new TocHighlighter(toc);
  21. tocHighlighter.highlight();
  22. }
  23. }, false);