diff --git a/js/src/forum/components/AffixedSidebar.js b/js/src/forum/components/AffixedSidebar.js
index 671ba591a..cb11238b0 100644
--- a/js/src/forum/components/AffixedSidebar.js
+++ b/js/src/forum/components/AffixedSidebar.js
@@ -1,10 +1,33 @@
import Component from '../../common/Component';
+/**
+ * The `AffixedSidebar` component uses Bootstrap's "affix" plugin to keep a
+ * sidebar navigation at the top of the viewport when scrolling.
+ *
+ * ### Children
+ *
+ * The component must wrap an element that itself wraps an
element, which
+ * will be "affixed".
+ *
+ * @see https://getbootstrap.com/docs/3.4/javascript/#affix
+ */
export default class AffixedSidebar extends Component {
view(vnode) {
return vnode.children[0];
}
+ oncreate(vnode) {
+ super.oncreate(vnode);
+
+ // Register the affix plugin to execute on every window resize (and trigger)
+ this.boundOnresize = this.onresize.bind(this);
+ $(window).on('resize', this.boundOnresize).resize();
+ }
+
+ onremove() {
+ $(window).off('resize', this.boundOnresize);
+ }
+
onresize() {
const $sidebar = this.$();
const $header = $('#header');
@@ -25,16 +48,4 @@ export default class AffixedSidebar extends Component {
},
});
}
-
- oncreate(vnode) {
- super.oncreate(vnode);
-
- // Register the affix plugin to execute on every window resize (and trigger)
- this.boundOnresize = this.onresize.bind(this);
- $(window).on('resize', this.boundOnresize).resize();
- }
-
- onremove() {
- $(window).off('resize', this.boundOnresize);
- }
}