webpack-bootstrap-ui-kit/src/js/_components/_ui.sidebar.js

48 lines
949 B
JavaScript
Raw Normal View History

2020-01-29 10:09:39 +01:00
'use strict';
import StickySidebar from 'sticky-sidebar/src/sticky-sidebar';
import Events from '../_events';
const SidebarUI = (($) => {
const D = document;
const W = window;
const $Body = $('html,body');
const NAME = 'SidebarUI';
const CLASSNAME = `js${NAME}`;
class SidebarUI {
static init() {
const ui = this;
ui.dispose();
2020-01-29 17:08:34 +01:00
if (!$(`.${CLASSNAME}`).length) {
return;
}
2020-01-29 10:09:39 +01:00
console.log(`Initializing: ${NAME}`);
const sticky = new StickySidebar(`.${CLASSNAME}`, {
innerWrapperSelector: `.${CLASSNAME}__inner`,
});
$Body.on(`${Events.SCROLL} ${Events.RESIZE}`, (e) => {
sticky.updateSticky(e);
});
}
static dispose() {
console.log(`Destroying: ${NAME}`);
}
}
$(W).on(`${Events.AJAX} ${Events.LOADED}`, () => {
SidebarUI.init();
});
W.SidebarUI = new SidebarUI();
return SidebarUI;
})($);
export default SidebarUI;