Files
Ghost-Theme-Source/assets/js/main.js
Sodbileg Gansukh c060944364 Fixed mobile scrolling issues
fixes #12

- added background color to the mobile menu actions
- disabled root scrolling when the mobile menu is opened which fixes the duplicate scrolling issue
2024-01-03 12:20:49 +07:00

48 lines
1.5 KiB
JavaScript

/* Mobile menu burger toggle */
(function () {
const navigation = document.querySelector('.gh-navigation');
const burger = navigation.querySelector('.gh-burger');
if (!burger) return;
burger.addEventListener('click', function () {
if (!navigation.classList.contains('is-open')) {
navigation.classList.add('is-open');
document.documentElement.style.overflowY = 'hidden';
} else {
navigation.classList.remove('is-open');
document.documentElement.style.overflowY = null;
}
});
})();
/* Add lightbox to gallery images */
(function () {
lightbox(
'.kg-image-card > .kg-image[width][height], .kg-gallery-image > img'
);
})();
/* Responsive video in post content */
(function () {
const sources = [
'.gh-content iframe[src*="youtube.com"]',
'.gh-content iframe[src*="youtube-nocookie.com"]',
'.gh-content iframe[src*="player.vimeo.com"]',
'.gh-content iframe[src*="kickstarter.com"][src*="video.html"]',
'.gh-content object',
'.gh-content embed',
];
reframe(document.querySelectorAll(sources.join(',')));
})();
/* Turn the main nav into dropdown menu when there are more than 5 menu items */
(function () {
dropdown();
})();
/* Infinite scroll pagination */
(function () {
if (!document.body.classList.contains('home-template') && !document.body.classList.contains('post-template')) {
pagination();
}
})();