Skip to content

Commit c435a69

Browse files
authored
Website Update
1 parent b748d2a commit c435a69

2 files changed

Lines changed: 67 additions & 8 deletions

File tree

docs/assets/js/shell.js

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@
9696
}
9797
}
9898

99+
function getScrollTop() {
100+
const scrollEl = document.scrollingElement || document.documentElement || document.body;
101+
return Math.max(
102+
window.scrollY || 0,
103+
window.pageYOffset || 0,
104+
scrollEl?.scrollTop || 0
105+
);
106+
}
107+
99108
function createSettledScheduler(callback) {
100109
const timers = [];
101110

@@ -334,6 +343,61 @@
334343
});
335344
}
336345

346+
function initOrientationRecovery(){
347+
let lastPortrait = isPortraitMobile();
348+
let lastStableScrollY = getScrollTop();
349+
let pendingRecovery = null;
350+
351+
const updateStableState = () => {
352+
lastPortrait = isPortraitMobile();
353+
lastStableScrollY = getScrollTop();
354+
};
355+
356+
const settledRecovery = createSettledScheduler(() => {
357+
if (pendingRecovery && isPortraitMobile() && !pendingRecovery.previousPortrait){
358+
const currentY = getScrollTop();
359+
if (Math.abs(currentY - pendingRecovery.scrollY) > 1){
360+
window.scrollTo({ top: pendingRecovery.scrollY, behavior: 'auto' });
361+
}
362+
}
363+
364+
pendingRecovery = null;
365+
updateStableState();
366+
});
367+
368+
window.addEventListener('scroll', () => {
369+
lastStableScrollY = getScrollTop();
370+
}, { passive:true });
371+
372+
window.addEventListener('orientationchange', () => {
373+
pendingRecovery = {
374+
previousPortrait: lastPortrait,
375+
scrollY: lastStableScrollY
376+
};
377+
settledRecovery.schedule(160);
378+
});
379+
380+
window.addEventListener('resize', () => {
381+
if (pendingRecovery){
382+
settledRecovery.schedule(120);
383+
return;
384+
}
385+
updateStableState();
386+
});
387+
388+
window.addEventListener('pageshow', updateStableState);
389+
390+
if (window.visualViewport){
391+
const syncViewportRecovery = () => {
392+
if (!pendingRecovery) return;
393+
settledRecovery.schedule(120);
394+
};
395+
396+
window.visualViewport.addEventListener('resize', syncViewportRecovery);
397+
window.visualViewport.addEventListener('scroll', syncViewportRecovery);
398+
}
399+
}
400+
337401
function initNavBackdrop(){
338402
if (document.body.dataset.backdropInit === '1') return;
339403
document.body.dataset.backdropInit = '1';
@@ -343,13 +407,7 @@
343407
let ticking = false;
344408

345409
const getScrolled = () => {
346-
const scrollEl = document.scrollingElement || document.documentElement || document.body;
347-
const y = Math.max(
348-
window.scrollY || 0,
349-
window.pageYOffset || 0,
350-
scrollEl?.scrollTop || 0
351-
);
352-
return y > 4;
410+
return getScrollTop() > 4;
353411
};
354412

355413
const resetBackdropState = () => {
@@ -1134,6 +1192,7 @@
11341192
renderProjects();
11351193
initYear();
11361194
initNav();
1195+
initOrientationRecovery();
11371196
syncMobileNavState();
11381197
initAnchorScroll();
11391198
initSectionSpy();

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,6 @@ <h2>Live Modules</h2>
133133

134134
<div id="footer-slot"></div>
135135

136-
<script src="assets/js/shell.js?v=20260321g" defer></script>
136+
<script src="assets/js/shell.js?v=20260321h" defer></script>
137137
</body>
138138
</html>

0 commit comments

Comments
 (0)