You've already forked Ghost-Theme-Source
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
This commit is contained in:
48
assets/js/main.js
Normal file
48
assets/js/main.js
Normal file
@@ -0,0 +1,48 @@
|
||||
/* 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();
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user