webpack-bootstrap-ui-kit/src/js_old/_components/_ui.shrink.js

49 lines
913 B
JavaScript
Raw Normal View History

2021-08-18 20:51:15 +02:00
"use strict";
2019-06-08 17:20:51 +02:00
2021-08-18 20:51:15 +02:00
import $ from "jquery";
import Events from "../_events";
2019-06-08 17:20:51 +02:00
const ShrinkUI = (($) => {
// Constants
2020-08-03 23:15:00 +02:00
const W = window;
2019-06-08 17:20:51 +02:00
const D = document;
2021-08-18 20:51:15 +02:00
const NAME = "ShrinkUI";
2019-06-08 17:20:51 +02:00
2020-08-03 23:15:00 +02:00
console.log(`${NAME}: init`);
2021-08-18 20:51:15 +02:00
$(W).on(
`${NAME}.init ${Events.LOADED} ${Events.SCROLL} ${Events.RESIZE}`,
() => {
if ($("#Navigation > .navbar-collapse").hasClass("show")) {
return;
}
let h1 = $("#SiteWideMessage").height();
if (!h1) {
h1 = 0;
}
let h2 = $("#SiteWideOffline").height();
if (!h2) {
h2 = 0;
}
let h3 = $("#Header").height();
if (!h3) {
h3 = 0;
}
const headerHeight = h1 + h2 + h3;
if ($(D).scrollTop() > headerHeight) {
$("body").addClass("shrink");
} else {
$("body").removeClass("shrink");
}
2020-08-08 16:23:42 +02:00
}
2021-08-18 20:51:15 +02:00
);
2019-06-08 17:20:51 +02:00
return ShrinkUI;
})($);
export default ShrinkUI;