Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | 44x 7x 7x 7x 6x 2x 2x 2x 2x 1x 1x 1x 1x 1x 9x 9x 9x 1x 1x 1x 1x 1x 1x 2x 2x 1x 1x 1x 2x 9x 9x 9x 2x 7x 7x 7x 7x 7x 7x 7x 7x 7x 6x 1x 1x 5x 5x 5x 5x 5x 7x 7x 7x 4x 4x 3x 3x 3x 3x 3x 3x 7x 1x 1x 7x 1x 1x 1x 7x 2x 1x 4x 4x 3x 3x 1x 1x 1x 7x 7x 7x 1x 6x 1x 7x 7x 7x 7x 7x 7x 6x 6x 7x 14x 14x 6x 6x 1x 1x 1x 1x 1x 6x 6x 3x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 1x 3x 2x 4x | /* PAGES.JS - Page-Specific Initialization ==============================================
Copyright 2025, Mark Forscher */
/* ======================================================================================= */
import { Utils } from './utils.js';
export class Pages {
constructor() {
this._resizeHandler = null;
}
// Initialize page-specific functionality
initPageSpecific() {
try {
// Read pageType from data attribute (CSP-compliant method)
const pageType = document.body.dataset.pageType;
if (pageType) {
switch(pageType) {
case "default":
// Default layout - check for specific page types
this.initDefaultPage();
break;
case "project":
this.projectInit();
break;
case "post":
this.postInit();
break;
case "album-promo":
this.albumPromoInit();
break;
default:
}
}
} catch (error) {
console.error('Page-specific initialization failed:', error);
}
}
// Initialize default layout pages
initDefaultPage() {
try {
const pageTitle = document.body.id;
switch(pageTitle) {
case "Home":
this.indexInit();
break;
case "Info":
this.infoInit();
break;
case "Contact":
this.connectInit();
break;
case "Journal":
this.journalInit();
break;
case "Under After Records":
this.recordsInit();
break;
default:
}
} catch (error) {
console.error('Default page initialization failed:', error);
}
}
// Page-specific initialization functions
indexInit() {
}
infoInit() {
}
connectInit() {
}
journalInit() {
this.initJournalMasonry();
}
recordsInit() {
try {
const recordsItems = document.querySelectorAll('.records-item');
if (!recordsItems || recordsItems.length === 0) {
return; // No records items on page
}
// Create hover image element
const hoverImage = document.createElement('div');
hoverImage.id = 'hover-image';
document.body.appendChild(hoverImage);
let targetX = 0; // Target mouse position
let targetY = 0;
let currentX = 0; // Current hover image position
let currentY = 0;
let animationFrameId = null;
let isHovering = false;
// Smooth animation loop with cleanup tracking (only runs when hovering)
function animateHoverImage() {
if (!isHovering) {
animationFrameId = null;
return; // Stop animation when not hovering
}
const easingFactor = 0.1; // Adjust for more or less delay
currentX += (targetX - currentX) * easingFactor;
currentY += (targetY - currentY) * easingFactor;
hoverImage.style.transform = `translate(${currentX}px, ${currentY}px)`;
animationFrameId = requestAnimationFrame(animateHoverImage);
}
// Add cleanup on page unload
window.addEventListener('beforeunload', () => {
if (animationFrameId) {
cancelAnimationFrame(animationFrameId);
}
if (hoverImage && hoverImage.parentNode) {
hoverImage.parentNode.removeChild(hoverImage);
}
}, { once: true });
// Initialize each records item
recordsItems.forEach(item => {
// Hover logic
item.addEventListener('mouseenter', () => {
const imageUrl = item.getAttribute('data-cover');
if (imageUrl) {
hoverImage.style.backgroundImage = `url(${imageUrl})`;
hoverImage.style.opacity = '1'; // Show the hover image
hoverImage.style.transform = 'translate(-50%, -50%) scale(1)'; // Scale up
isHovering = true;
// Start animation loop if not already running
Eif (!animationFrameId) {
animateHoverImage();
}
}
});
item.addEventListener('mousemove', (e) => {
targetX = e.pageX + 20; // Offset from the mouse
targetY = e.pageY + 20;
});
item.addEventListener('mouseleave', () => {
hoverImage.style.opacity = '0'; // Hide the hover image
hoverImage.style.transform = 'translate(-50%, -50%) scale(0.8)'; // Scale down
isHovering = false;
// Animation will stop automatically on next frame
});
// Click logic for expanding/collapsing
item.addEventListener('click', () => {
item.classList.toggle('expanded');
});
});
} catch (error) {
console.error('Records page initialization failed:', error);
}
}
workInit() {
}
projectInit() {
}
postInit() {
}
albumPromoInit() {
}
// Modern vanilla JS masonry implementation for journal page
initJournalMasonry() {
const grid = Utils.$1('.masonry-grid');
if (!grid) {
console.error("Journal masonry grid not found!");
return;
}
// Initialize CSS Grid masonry
this.setupCSSMasonry(grid);
// Setup lazy loading for journal images
this.initJournalLazyLoading(grid);
// Force layout after a short delay
setTimeout(() => this.updateJournalLayout(grid), 100);
}
// Setup CSS-based masonry layout
setupCSSMasonry(grid) {
// Apply CSS Grid masonry styles with responsive columns
const windowWidth = window.innerWidth;
let columns = '1fr 1fr 1fr 1fr'; // 4 columns default
if (windowWidth <= 600) {
columns = '1fr 1fr'; // 2 columns on mobile
} else if (windowWidth <= 1000) {
columns = '1fr 1fr 1fr'; // 3 columns on tablet
}
grid.style.display = 'grid';
grid.style.gridTemplateColumns = columns;
grid.style.gridAutoRows = '10px';
grid.style.gap = '40px';
grid.style.alignItems = 'start';
// Listen for window resize to update layout (debounced)
if (!this._resizeHandler) {
this._resizeHandler = Utils.debounce(() => {
this.animatedResizeUpdate(grid);
}, 150); // Faster debounce for snappier response
window.addEventListener('resize', this._resizeHandler);
}
// Calculate and set grid row spans for each item
this.updateJournalLayout(grid);
}
// Update layout by calculating grid spans
updateJournalLayout(grid) {
const items = grid.querySelectorAll('.journal-items-item');
items.forEach(item => {
const img = item.querySelector('img:not(.spinner)');
if (img && img.complete && img.naturalHeight > 0) {
const rowHeight = 10; // matches gridAutoRows
const rowGap = 40; // matches gap
const itemHeight = item.offsetHeight;
const rowSpan = Math.ceil((itemHeight + rowGap) / (rowHeight + rowGap));
item.style.gridRowEnd = `span ${rowSpan}`;
}
});
}
// Vanilla JS lazy loading for journal images
initJournalLazyLoading(grid) {
const lazyImages = grid.querySelectorAll('.lazy');
if (lazyImages.length === 0) return;
const imageObserver = new IntersectionObserver(
(entries) => {
entries.forEach(entry => {
Eif (entry.isIntersecting) {
const img = entry.target;
const newSrc = img.dataset.src;
Eif (newSrc) {
// Preload image
const tempImg = new Image();
tempImg.onload = () => {
img.src = newSrc;
img.classList.remove('lazy');
img.classList.add('lazy-loaded');
// Remove spinner
const spinner = img.closest('.journal-item-img').querySelector('.spinner');
Eif (spinner) {
spinner.remove();
}
// Mark item as ready and trigger fade-in
const parentItem = img.closest('.journal-items-item');
parentItem.classList.add('image-loaded');
// Trigger fade-in if item is in viewport with stagger delay
Eif (Utils.isElementVisible(parentItem)) {
const allItems = grid.querySelectorAll('.journal-items-item');
const itemIndex = Array.from(allItems).indexOf(parentItem);
setTimeout(() => {
parentItem.classList.add('visible');
}, itemIndex * 150); // Stagger delay
}
// Update masonry layout after image loads
setTimeout(() => this.updateJournalLayout(grid), 100);
};
tempImg.src = newSrc;
}
imageObserver.unobserve(img);
}
});
},
{
rootMargin: '200px 0px',
threshold: 0.1
}
);
lazyImages.forEach(img => {
imageObserver.observe(img);
});
// Fallback layout update
setTimeout(() => this.updateJournalLayout(grid), 2000);
}
// Animated resize update for smooth repositioning
animatedResizeUpdate(grid) {
const items = grid.querySelectorAll('.journal-items-item');
// Capture current positions
const oldPositions = Array.from(items).map(item => {
const rect = item.getBoundingClientRect();
return {
element: item,
x: rect.left,
y: rect.top
};
});
// Update the grid layout (skip resize handler setup to prevent recursion)
this.updateGridColumns(grid);
// Force layout calculation
grid.offsetHeight;
// Update individual item positions
this.updateJournalLayout(grid);
// Force another layout calculation
grid.offsetHeight;
// Calculate new positions and animate
items.forEach((item, index) => {
const oldPos = oldPositions[index];
const newRect = item.getBoundingClientRect();
const deltaX = oldPos.x - newRect.left;
const deltaY = oldPos.y - newRect.top;
// Only animate if position actually changed
if (Math.abs(deltaX) > 1 || Math.abs(deltaY) > 1) {
// Set initial position to old position
item.style.transform = `translate(${deltaX}px, ${deltaY}px)`;
item.style.transition = 'none';
// Force reflow
item.offsetHeight;
// Animate to new position
item.style.transition = 'transform 0.25s cubic-bezier(0.4, 0.0, 0.2, 1)';
item.style.transform = 'translate(0, 0)';
// Clean up after animation
setTimeout(() => {
item.style.transform = '';
item.style.transition = '';
}, 250);
}
});
}
// Update grid columns without setting up resize handlers
updateGridColumns(grid) {
const windowWidth = window.innerWidth;
let columns = '1fr 1fr 1fr 1fr'; // 4 columns default
if (windowWidth <= 600) {
columns = '1fr 1fr'; // 2 columns on mobile
} else if (windowWidth <= 1200) {
columns = '1fr 1fr 1fr'; // 3 columns on tablet
}
grid.style.gridTemplateColumns = columns;
}
}
|