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

44 lines
884 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();
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;