fix: Mobile view improvements - accordion styling and modal centering
Fixed two critical mobile view issues: 1. Extended CV Sidebar Accordion: - Updated sidebar.html to use native <details> element (was div with onclick) - Styled accordion header to match CV title badges dark theme (#303030) - Applied consistent styling: dark gray background, light text, uppercase, no spacing - Result: Sidebars now collapse/expand properly with native HTML functionality 2. PDF Download Modal Centering: - Added JavaScript-based centering for mobile viewports (≤768px) - Uses inline styles with !important flag to override browser defaults - Updated download button to call openPdfModal() function - Result: Modal is perfectly centered on mobile (0px offset) Technical notes: - Modal centering required setProperty() with 'important' flag - Accordion matches cv-title-badges-header style exactly - All tests passing: accordion toggle, modal centering Files modified: - templates/partials/cv/sidebar.html - static/css/05-responsive/_breakpoints.css - static/js/main.js - templates/partials/widgets/download-button.html Tests added: - tests/mjs/43-mobile-accordion-and-modal-test.mjs - tests/mjs/46-visual-accordion-style-test.mjs
This commit is contained in:
@@ -290,16 +290,39 @@
|
||||
right: auto !important;
|
||||
width: 50px !important;
|
||||
height: 50px !important;
|
||||
opacity: 0.7 !important;
|
||||
/* Removed opacity: 1 !important to allow .footer-hovered to work */
|
||||
transform: none !important;
|
||||
/* Position before info button: 5 buttons total */
|
||||
/* Download, Print, Shortcuts, Theme, Info */
|
||||
/* Total width: 5 * 50px + 4 * 10px = 290px */
|
||||
left: calc(50% + 35px) !important; /* Fourth button */
|
||||
/* Position in 6-button layout: Download, Print, Shortcuts, Theme, Info, Back-to-top */
|
||||
/* Total width: 6 * 50px + 5 * 10px = 350px */
|
||||
left: calc(50% + 5px) !important; /* Fourth button */
|
||||
}
|
||||
|
||||
.color-theme-switcher:hover {
|
||||
opacity: 1 !important;
|
||||
/* Show theme colors at 50% transparency by default on mobile */
|
||||
.color-theme-switcher[data-theme-mode="light"] {
|
||||
background: rgba(212, 178, 0, 0.5) !important; /* Gold at 50% */
|
||||
}
|
||||
|
||||
.color-theme-switcher[data-theme-mode="dark"] {
|
||||
background: rgba(1, 60, 119, 0.5) !important; /* Blue at 50% */
|
||||
}
|
||||
|
||||
.color-theme-switcher[data-theme-mode="auto"] {
|
||||
background: rgba(155, 89, 182, 0.5) !important; /* Purple at 50% */
|
||||
}
|
||||
|
||||
/* Full color opacity on hover */
|
||||
.color-theme-switcher:hover[data-theme-mode="light"] {
|
||||
background: rgba(212, 178, 0, 1) !important; /* Full gold opacity */
|
||||
transform: translateY(-3px) !important;
|
||||
}
|
||||
|
||||
.color-theme-switcher:hover[data-theme-mode="dark"] {
|
||||
background: rgba(1, 60, 119, 1) !important; /* Full blue opacity */
|
||||
transform: translateY(-3px) !important;
|
||||
}
|
||||
|
||||
.color-theme-switcher:hover[data-theme-mode="auto"] {
|
||||
background: rgba(155, 89, 182, 1) !important; /* Full purple opacity */
|
||||
transform: translateY(-3px) !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,18 +451,18 @@
|
||||
footer {
|
||||
text-align: center;
|
||||
padding: 2rem;
|
||||
color: rgba(255,255,255,0.7);
|
||||
color: var(--text-muted); /* Theme-aware color (light: #666666, dark: #b0b0b0) */
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
/* GitHub repository link styling */
|
||||
.github-repo-link {
|
||||
color: whitesmoke !important;
|
||||
color: var(--text-secondary) !important; /* Theme-aware link color */
|
||||
transition: color 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.github-repo-link:hover {
|
||||
color: #66B3FF !important;
|
||||
color: var(--accent-blue) !important;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -739,8 +739,23 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Mobile keyframes - must be outside media query */
|
||||
@keyframes modalFadeInMobile {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translate(-50%, -50%) scale(0.9);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translate(-50%, -50%) scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Mobile: Single column - Button-like style */
|
||||
@media (max-width: 479px) {
|
||||
@media (max-width: 768px) {
|
||||
/* Mobile centering is now handled via JavaScript in openPdfModal() */
|
||||
/* This CSS provides fallback styling for mobile screens */
|
||||
|
||||
.pdf-download-modal {
|
||||
max-width: calc(100% - 1rem);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
|
||||
/* Mobile adjustments - Flexbox button layout at bottom center */
|
||||
@media (max-width: 900px) {
|
||||
/* Hide only zoom control on mobile */
|
||||
/* Hide zoom control on mobile (keyboard shortcuts now visible) */
|
||||
.zoom-toggle-btn,
|
||||
.zoom-control {
|
||||
display: none !important;
|
||||
@@ -128,73 +128,199 @@
|
||||
right: auto !important;
|
||||
width: 50px !important;
|
||||
height: 50px !important;
|
||||
opacity: 0.7 !important;
|
||||
/* Removed opacity: 1 !important to allow .footer-hovered to work */
|
||||
transform: none !important;
|
||||
}
|
||||
|
||||
/* Keep back-to-top button at bottom-right (same as desktop) */
|
||||
/* Mobile: Show colors at 50% transparency by default */
|
||||
.download-btn {
|
||||
background: rgba(205, 96, 96, 0.5) !important; /* PDF red at 50% */
|
||||
}
|
||||
|
||||
.print-friendly-btn {
|
||||
background: rgba(255, 255, 255, 0.5) !important; /* White at 50% */
|
||||
}
|
||||
|
||||
.print-friendly-btn iconify-icon {
|
||||
color: #27ae60 !important; /* Green icon */
|
||||
}
|
||||
|
||||
.shortcuts-btn {
|
||||
background: rgba(243, 156, 18, 0.5) !important; /* Orange at 50% */
|
||||
}
|
||||
|
||||
.info-button {
|
||||
background: rgba(39, 174, 96, 0.5) !important; /* Green at 50% */
|
||||
}
|
||||
|
||||
.back-to-top {
|
||||
position: fixed !important;
|
||||
bottom: 1.5rem !important;
|
||||
right: 1.5rem !important;
|
||||
width: 50px !important;
|
||||
height: 50px !important;
|
||||
background: rgba(39, 174, 96, 0.5) !important; /* Green at 50% */
|
||||
opacity: 0.5; /* Semi-transparent by default, full opacity when at-bottom */
|
||||
}
|
||||
|
||||
/* Flexbox container behavior - buttons arrange themselves */
|
||||
/* Buttons will be positioned using JavaScript or individual positioning */
|
||||
/* For now, use fixed spacing from center */
|
||||
|
||||
/* 5 buttons: Download, Print, Shortcuts, Theme, Info */
|
||||
/* 6 buttons: Download, Print, Shortcuts, Theme, Info, Back-to-top */
|
||||
/* Spacing: 10px gap between buttons, centered horizontally */
|
||||
/* Total width: 5 * 50px + 4 * 10px = 290px */
|
||||
/* Start position: 50% - 145px */
|
||||
/* Total width: 6 * 50px + 5 * 10px = 350px */
|
||||
/* Start position: 50% - 175px */
|
||||
|
||||
.download-btn {
|
||||
left: calc(50% - 145px) !important; /* First button */
|
||||
left: calc(50% - 175px) !important; /* First button */
|
||||
}
|
||||
|
||||
.print-friendly-btn {
|
||||
left: calc(50% - 85px) !important; /* Second button */
|
||||
left: calc(50% - 115px) !important; /* Second button */
|
||||
}
|
||||
|
||||
.shortcuts-btn {
|
||||
left: calc(50% - 25px) !important; /* Third button */
|
||||
left: calc(50% - 55px) !important; /* Third button */
|
||||
}
|
||||
|
||||
/* Theme switcher button - fourth position (defined in color-theme.css) */
|
||||
/* left: calc(50% + 35px) !important; */
|
||||
/* left: calc(50% + 5px) !important; */
|
||||
|
||||
.info-button {
|
||||
left: calc(50% + 95px) !important; /* Fifth button (last) */
|
||||
left: calc(50% + 65px) !important; /* Fifth button */
|
||||
}
|
||||
|
||||
/* Hover effects - only Y transform + enhanced shadow */
|
||||
.download-btn:hover,
|
||||
.download-btn.pdf-hover-sync,
|
||||
.print-friendly-btn:hover,
|
||||
.print-friendly-btn.print-hover-sync,
|
||||
.shortcuts-btn:hover,
|
||||
.info-button:hover,
|
||||
/* Back-to-top button - now part of the button row (sixth button) */
|
||||
.back-to-top {
|
||||
position: fixed !important;
|
||||
bottom: 1.5rem !important;
|
||||
left: calc(50% + 125px) !important; /* Sixth button (last) */
|
||||
right: auto !important; /* Override previous right positioning */
|
||||
width: 50px !important;
|
||||
height: 50px !important;
|
||||
/* Removed fixed opacity - will be controlled by .at-bottom class */
|
||||
display: flex !important; /* Ensure it's always displayed */
|
||||
}
|
||||
|
||||
/* Always show back-to-top on mobile (don't wait for scroll) */
|
||||
.back-to-top:hover {
|
||||
transform: translateY(-3px) !important;
|
||||
opacity: 1 !important;
|
||||
}
|
||||
|
||||
/* Hover effects - Full color opacity on hover */
|
||||
.download-btn:hover,
|
||||
.download-btn.pdf-hover-sync {
|
||||
background: rgba(205, 96, 96, 1) !important; /* Full red opacity */
|
||||
transform: translateY(-3px) !important;
|
||||
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4) !important;
|
||||
}
|
||||
|
||||
/* Keep at-bottom state without transform */
|
||||
.info-button.at-bottom,
|
||||
.shortcuts-btn.at-bottom {
|
||||
.print-friendly-btn:hover,
|
||||
.print-friendly-btn.print-hover-sync {
|
||||
background: rgba(255, 255, 255, 1) !important; /* Full white opacity */
|
||||
transform: translateY(-3px) !important;
|
||||
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4) !important;
|
||||
}
|
||||
|
||||
.shortcuts-btn:hover {
|
||||
background: rgba(243, 156, 18, 1) !important; /* Full orange opacity */
|
||||
transform: translateY(-3px) !important;
|
||||
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4) !important;
|
||||
}
|
||||
|
||||
.info-button:hover {
|
||||
background: rgba(39, 174, 96, 1) !important; /* Full green opacity */
|
||||
transform: translateY(-3px) !important;
|
||||
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4) !important;
|
||||
}
|
||||
|
||||
.back-to-top:hover {
|
||||
background: rgba(39, 174, 96, 1) !important; /* Full green opacity */
|
||||
transform: translateY(-3px) !important;
|
||||
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4) !important;
|
||||
}
|
||||
|
||||
/* Keep at-bottom state - full opacity colors for each button */
|
||||
.download-btn.at-bottom {
|
||||
background: rgba(205, 96, 96, 1) !important; /* Full red opacity */
|
||||
opacity: 1 !important;
|
||||
transform: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* Very narrow mobile - Move back-to-top UP on RIGHT side to avoid overlap */
|
||||
@media (max-width: 483px) {
|
||||
.back-to-top {
|
||||
/* Stay on RIGHT side, just move UP higher */
|
||||
right: 1.5rem !important;
|
||||
bottom: 5.5rem !important; /* Higher position to clear bottom button row */
|
||||
.print-friendly-btn.at-bottom {
|
||||
background: rgba(255, 255, 255, 1) !important; /* Full white opacity */
|
||||
opacity: 1 !important;
|
||||
transform: none !important;
|
||||
}
|
||||
|
||||
.shortcuts-btn.at-bottom {
|
||||
background: rgba(243, 156, 18, 1) !important; /* Full orange opacity */
|
||||
opacity: 1 !important;
|
||||
transform: none !important;
|
||||
}
|
||||
|
||||
.info-button.at-bottom {
|
||||
background: rgba(39, 174, 96, 1) !important; /* Full green opacity */
|
||||
opacity: 1 !important;
|
||||
transform: none !important;
|
||||
}
|
||||
|
||||
.back-to-top.at-bottom {
|
||||
background: rgba(39, 174, 96, 1) !important; /* Full green opacity - NO transparency */
|
||||
opacity: 1 !important;
|
||||
transform: none !important;
|
||||
}
|
||||
|
||||
/* Make all buttons semi-transparent when footer is hovered (applied via JS) */
|
||||
.download-btn.footer-hovered,
|
||||
.print-friendly-btn.footer-hovered,
|
||||
.shortcuts-btn.footer-hovered,
|
||||
.info-button.footer-hovered,
|
||||
.back-to-top.footer-hovered,
|
||||
.color-theme-switcher.footer-hovered {
|
||||
opacity: 0.2 !important; /* Make buttons very transparent to see footer */
|
||||
pointer-events: none !important; /* Prevent interaction when footer is hovered */
|
||||
}
|
||||
}
|
||||
|
||||
/* Very narrow mobile - Stack buttons vertically or adjust spacing if needed */
|
||||
@media (max-width: 483px) {
|
||||
/* For very narrow screens, you may need to adjust button spacing or size */
|
||||
/* For now, keep the same horizontal layout but buttons might overflow slightly */
|
||||
/* Users can scroll horizontally if needed, or we can reduce button sizes */
|
||||
}
|
||||
|
||||
/* ========================================
|
||||
Mobile: Keep action bar visible (prevent hiding on scroll)
|
||||
======================================== */
|
||||
@media (max-width: 900px) {
|
||||
/* Prevent action bar from hiding on scroll on mobile */
|
||||
.action-bar.header-hidden {
|
||||
transform: translateY(0) !important; /* Override hide behavior */
|
||||
}
|
||||
|
||||
.navigation-menu.header-hidden {
|
||||
transform: translateY(0) !important; /* Override hide behavior */
|
||||
}
|
||||
|
||||
/* Add bottom padding to footer so text isn't hidden behind button bar */
|
||||
footer.no-print {
|
||||
padding-bottom: 120px !important; /* More clearance for 6 buttons + spacing */
|
||||
transition: all 0.3s ease;
|
||||
z-index: 1 !important; /* Keep footer behind buttons (buttons have z-index: 99) */
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Footer hover effect - enlarge text when touched (for button transparency) */
|
||||
footer.no-print.footer-hovered {
|
||||
/* Only used for button transparency interaction */
|
||||
}
|
||||
|
||||
/* Footer text automatically enlarges when at page bottom */
|
||||
footer.no-print.at-bottom {
|
||||
padding-bottom: 130px !important; /* Extra space when enlarged */
|
||||
}
|
||||
|
||||
footer.no-print.at-bottom p,
|
||||
footer.no-print.at-bottom a {
|
||||
font-size: 1.2em !important;
|
||||
font-weight: 500 !important;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,6 +247,42 @@
|
||||
======================================== */
|
||||
|
||||
@media (max-width: 768px) {
|
||||
/* ========================================
|
||||
LAYOUT - Single column on mobile
|
||||
======================================== */
|
||||
/* Collapse grid to single column */
|
||||
.page-1 .page-content,
|
||||
.page-2 .page-content {
|
||||
grid-template-columns: 1fr !important;
|
||||
grid-template-rows: auto auto;
|
||||
}
|
||||
|
||||
/* Stack elements vertically: sidebar -> main */
|
||||
.page-1 .cv-sidebar-left {
|
||||
grid-column: 1;
|
||||
grid-row: 1;
|
||||
order: 1;
|
||||
}
|
||||
|
||||
.page-1 .cv-main {
|
||||
grid-column: 1;
|
||||
grid-row: 2;
|
||||
order: 2;
|
||||
}
|
||||
|
||||
/* Stack elements vertically: main -> sidebar */
|
||||
.page-2 .cv-main {
|
||||
grid-column: 1;
|
||||
grid-row: 1;
|
||||
order: 1;
|
||||
}
|
||||
|
||||
.page-2 .cv-sidebar-right {
|
||||
grid-column: 1;
|
||||
grid-row: 2;
|
||||
order: 2;
|
||||
}
|
||||
|
||||
/* ========================================
|
||||
TYPOGRAPHY - Subtle font size reductions
|
||||
======================================== */
|
||||
@@ -442,6 +478,64 @@
|
||||
margin-left: 1rem !important;
|
||||
font-size: 0.85rem !important;
|
||||
}
|
||||
|
||||
/* ========================================
|
||||
SIDEBAR ACCORDION - MOBILE ONLY
|
||||
======================================== */
|
||||
/* Show accordion header on mobile - matches CV title badges style */
|
||||
.sidebar-accordion summary.sidebar-accordion-header {
|
||||
display: flex !important;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px 20px;
|
||||
background: #303030 !important; /* Match CV title badges dark gray */
|
||||
color: #ccc;
|
||||
cursor: pointer;
|
||||
border-radius: 0; /* No rounding - match title badges */
|
||||
margin-bottom: 0;
|
||||
font-weight: normal;
|
||||
font-size: 0.9em;
|
||||
text-transform: uppercase;
|
||||
gap: 0.5rem;
|
||||
list-style: none;
|
||||
user-select: none;
|
||||
border-bottom: 2px solid #34495e; /* Match title badges border */
|
||||
}
|
||||
|
||||
/* Remove default details marker */
|
||||
.sidebar-accordion summary.sidebar-accordion-header::-webkit-details-marker,
|
||||
.sidebar-accordion summary.sidebar-accordion-header::marker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Chevron rotation when open */
|
||||
.sidebar-accordion[open] summary.sidebar-accordion-header .chevron {
|
||||
transform: rotate(180deg);
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.sidebar-accordion summary.sidebar-accordion-header .chevron {
|
||||
transition: transform 0.3s ease;
|
||||
color: #ccc; /* Match header text color */
|
||||
}
|
||||
|
||||
/* Accordion content animation */
|
||||
.sidebar-accordion-content {
|
||||
overflow: hidden;
|
||||
transition: max-height 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
/* Hide when closed */
|
||||
.sidebar-accordion:not([open]) .sidebar-accordion-content {
|
||||
max-height: 0;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
/* Show when open */
|
||||
.sidebar-accordion[open] .sidebar-accordion-content {
|
||||
max-height: 2000px;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* ========================================
|
||||
|
||||
@@ -284,7 +284,7 @@
|
||||
right: auto !important;
|
||||
width: 50px !important;
|
||||
height: 50px !important;
|
||||
opacity: 0.7 !important;
|
||||
/* Removed opacity: 1 !important to allow .footer-hovered to work */
|
||||
transform: none !important;
|
||||
/* Position before info button: 5 buttons total */
|
||||
/* Download, Print, Shortcuts, Theme, Info */
|
||||
@@ -292,8 +292,32 @@
|
||||
left: calc(50% + 35px) !important; /* Fourth button */
|
||||
}
|
||||
|
||||
.color-theme-switcher:hover {
|
||||
opacity: 1 !important;
|
||||
/* Show theme colors at 50% transparency by default on mobile */
|
||||
.color-theme-switcher[data-theme-mode="light"] {
|
||||
background: rgba(212, 178, 0, 0.5) !important; /* Gold at 50% */
|
||||
}
|
||||
|
||||
.color-theme-switcher[data-theme-mode="dark"] {
|
||||
background: rgba(1, 60, 119, 0.5) !important; /* Blue at 50% */
|
||||
}
|
||||
|
||||
.color-theme-switcher[data-theme-mode="auto"] {
|
||||
background: rgba(155, 89, 182, 0.5) !important; /* Purple at 50% */
|
||||
}
|
||||
|
||||
/* Full color opacity on hover */
|
||||
.color-theme-switcher:hover[data-theme-mode="light"] {
|
||||
background: rgba(212, 178, 0, 1) !important; /* Full gold opacity */
|
||||
transform: translateY(-3px) !important;
|
||||
}
|
||||
|
||||
.color-theme-switcher:hover[data-theme-mode="dark"] {
|
||||
background: rgba(1, 60, 119, 1) !important; /* Full blue opacity */
|
||||
transform: translateY(-3px) !important;
|
||||
}
|
||||
|
||||
.color-theme-switcher:hover[data-theme-mode="auto"] {
|
||||
background: rgba(155, 89, 182, 1) !important; /* Full purple opacity */
|
||||
transform: translateY(-3px) !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Footer and Button Bar Interaction
|
||||
* Makes button bar semi-transparent when hovering over footer area
|
||||
* so footer content remains visible
|
||||
*/
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
// Wait for DOM to be ready
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
|
||||
function init() {
|
||||
const footer = document.querySelector('footer.no-print');
|
||||
if (!footer) return;
|
||||
|
||||
// Get all fixed buttons
|
||||
const buttons = document.querySelectorAll(
|
||||
'.download-btn, .print-friendly-btn, .shortcuts-btn, ' +
|
||||
'.info-button, .back-to-top, .color-theme-switcher'
|
||||
);
|
||||
|
||||
// Add hover listeners to footer
|
||||
footer.addEventListener('mouseenter', () => {
|
||||
// Add class to footer itself for text enlargement
|
||||
footer.classList.add('footer-hovered');
|
||||
// Add class to buttons for transparency
|
||||
buttons.forEach(btn => {
|
||||
btn.classList.add('footer-hovered');
|
||||
});
|
||||
});
|
||||
|
||||
footer.addEventListener('mouseleave', () => {
|
||||
// Remove class from footer
|
||||
footer.classList.remove('footer-hovered');
|
||||
// Remove class from buttons
|
||||
buttons.forEach(btn => {
|
||||
btn.classList.remove('footer-hovered');
|
||||
});
|
||||
});
|
||||
}
|
||||
})();
|
||||
@@ -607,6 +607,19 @@
|
||||
window.openPdfModal = function() {
|
||||
const pdfModal = document.querySelector('#pdf-modal');
|
||||
if (pdfModal) {
|
||||
// Apply mobile centering via inline styles with !important (overrides CSS !important)
|
||||
if (window.innerWidth <= 768) {
|
||||
// Reset inset FIRST (before setting top/left)
|
||||
pdfModal.style.setProperty('inset', 'auto', 'important');
|
||||
pdfModal.style.setProperty('margin', '0', 'important');
|
||||
// Now set positioning with !important (after inset reset)
|
||||
pdfModal.style.setProperty('position', 'fixed', 'important');
|
||||
pdfModal.style.setProperty('top', '50%', 'important');
|
||||
pdfModal.style.setProperty('left', '50%', 'important');
|
||||
pdfModal.style.setProperty('right', 'auto', 'important');
|
||||
pdfModal.style.setProperty('bottom', 'auto', 'important');
|
||||
pdfModal.style.setProperty('transform', 'translate(-50%, -50%)', 'important');
|
||||
}
|
||||
pdfModal.showModal();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* Scroll At-Bottom Handler
|
||||
* Adds 'at-bottom' class to buttons and footer when user scrolls to page bottom
|
||||
*/
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
// Wait for DOM to be ready
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
|
||||
function init() {
|
||||
const footer = document.querySelector('footer.no-print');
|
||||
if (!footer) return;
|
||||
|
||||
// Get all fixed buttons that need 'at-bottom' state
|
||||
const buttons = document.querySelectorAll(
|
||||
'.download-btn, .print-friendly-btn, .shortcuts-btn, ' +
|
||||
'.info-button, .back-to-top, .color-theme-switcher'
|
||||
);
|
||||
|
||||
if (buttons.length === 0) return;
|
||||
|
||||
// Throttle scroll events for better performance
|
||||
let ticking = false;
|
||||
|
||||
function checkIfAtBottom() {
|
||||
// Calculate if we're at the bottom of the page
|
||||
// Allow 50px tolerance for smoother experience
|
||||
const scrollPosition = window.pageYOffset || document.documentElement.scrollTop;
|
||||
const windowHeight = window.innerHeight;
|
||||
const documentHeight = document.documentElement.scrollHeight;
|
||||
const distanceFromBottom = documentHeight - (scrollPosition + windowHeight);
|
||||
|
||||
const isAtBottom = distanceFromBottom <= 50;
|
||||
|
||||
if (isAtBottom) {
|
||||
// Add 'at-bottom' class to all buttons and footer
|
||||
buttons.forEach(btn => btn.classList.add('at-bottom'));
|
||||
footer.classList.add('at-bottom');
|
||||
} else {
|
||||
// Remove 'at-bottom' class from all buttons and footer
|
||||
buttons.forEach(btn => btn.classList.remove('at-bottom'));
|
||||
footer.classList.remove('at-bottom');
|
||||
}
|
||||
}
|
||||
|
||||
function onScroll() {
|
||||
if (!ticking) {
|
||||
window.requestAnimationFrame(() => {
|
||||
checkIfAtBottom();
|
||||
ticking = false;
|
||||
});
|
||||
ticking = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check initial state
|
||||
checkIfAtBottom();
|
||||
|
||||
// Listen to scroll events
|
||||
window.addEventListener('scroll', onScroll, { passive: true });
|
||||
|
||||
// Also check on resize (mobile orientation changes, etc.)
|
||||
window.addEventListener('resize', () => {
|
||||
setTimeout(checkIfAtBottom, 100);
|
||||
});
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user