mirror of
https://github.com/conventional-commits/conventionalcommits.org.git
synced 2024-11-15 02:45:15 +01:00
38 lines
815 B
JavaScript
38 lines
815 B
JavaScript
import AnchorJS from 'anchor-js';
|
|
|
|
class App {
|
|
constructor(anchors) {
|
|
this.anchors = anchors;
|
|
this.onInit();
|
|
}
|
|
|
|
_addEventListeners() {
|
|
// using 'load' instead of 'DOMContentLoaded' because we want to wait the css
|
|
// https://javascript.info/onload-ondomcontentloaded
|
|
window.addEventListener('load', () => {
|
|
// wrapped in a timeout for wait css parsing
|
|
setTimeout(() => this._onPageLoaded(), 0);
|
|
});
|
|
}
|
|
|
|
_onPageLoaded() {
|
|
this.removeLoadingClass();
|
|
}
|
|
|
|
onInit() {
|
|
this.addAnchorsLinks();
|
|
this._addEventListeners();
|
|
}
|
|
|
|
addAnchorsLinks() {
|
|
this.anchors.options = {placement: 'left'};
|
|
this.anchors.add();
|
|
}
|
|
|
|
removeLoadingClass() {
|
|
document.body.classList.remove('conventional-commits--loading');
|
|
}
|
|
}
|
|
|
|
const app = new App(new AnchorJS());
|