Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Sticky navbar check if navbar element exists

givanz09bc23e321e3
diff --git a/public/js/app/theme.js b/public/js/app/theme.js
index af7411c..9b6ca47 100644
--- a/public/js/app/theme.js
+++ b/public/js/app/theme.js
@@ -12,7 +12,7 @@ window.onscroll = function() {navbarSticky()};
// Get the navbar
var navbar = document.querySelector((typeof navbarSelector !== 'undefined') ? navbarSelector : ".navbar");
// Get the offset position of the navbar
-var sticky = navbar.offsetTop ? navbar.offsetTop : navbar.offsetHeight;
+var sticky = navbar ? (navbar.offsetTop ? navbar.offsetTop : navbar.offsetHeight) : 0;
function toggleNavbarTheme () {
if (navbar.classList.contains("navbar-dark")) {
@@ -27,6 +27,7 @@ function toggleNavbarTheme () {
// Add the sticky class to the navbar when you reach its scroll position. Remove "sticky" when you leave the scroll position
function navbarSticky(isSticky) {
+ if (!navbar) return;
if (isSticky == undefined) {
isSticky = (window.pageYOffset >= sticky);
}