Skip to content

Commit 26a6d43

Browse files
perf: resolve startup forced reflows, debounce resize layout, and optimize touch targets
1 parent f87264e commit 26a6d43

4 files changed

Lines changed: 116 additions & 18 deletions

File tree

desktop-app/resources/js/script.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5073,12 +5073,17 @@ document.addEventListener("DOMContentLoaded", function () {
50735073

50745074
initTabs();
50755075
if (loadGlobalState().syncScrollingEnabled === false) toggleSyncScrolling();
5076-
initEditorGeometry();
5077-
refreshEditorWidth();
50785076
updateMobileStats();
50795077
updateFindHighlights();
50805078
syncHighlightScroll();
50815079

5080+
// Defer DOM geometry measurement until after FCP/LCP critical paint path
5081+
setTimeout(function() {
5082+
initEditorGeometry();
5083+
refreshEditorWidth();
5084+
scheduleLineNumberUpdate();
5085+
}, 100);
5086+
50825087
// Initialize resizer - Story 1.3
50835088
initResizer();
50845089
function constrainFloatingPanelPosition() {
@@ -5105,14 +5110,18 @@ document.addEventListener("DOMContentLoaded", function () {
51055110
lastFloatingTop = constrainedTop;
51065111
}
51075112

5113+
let resizeLayoutTimeout = null;
51085114
window.addEventListener('resize', () => {
5109-
initEditorGeometry();
5110-
refreshEditorWidth();
5111-
scheduleLineNumberUpdate();
5112-
if (window.innerWidth < 1080 && isFrDocked && isFindModalOpen) {
5113-
toggleFrDockMode(true);
5114-
}
5115-
constrainFloatingPanelPosition();
5115+
clearTimeout(resizeLayoutTimeout);
5116+
resizeLayoutTimeout = setTimeout(function() {
5117+
initEditorGeometry();
5118+
refreshEditorWidth();
5119+
scheduleLineNumberUpdate();
5120+
if (window.innerWidth < 1080 && isFrDocked && isFindModalOpen) {
5121+
toggleFrDockMode(true);
5122+
}
5123+
constrainFloatingPanelPosition();
5124+
}, 100);
51165125
});
51175126

51185127
// View Mode Button Event Listeners - Story 1.1

desktop-app/resources/styles.css

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,46 @@ a:focus {
18901890
position: relative;
18911891
}
18921892

1893+
/* Touch Hitbox Expansion for Tab Menu Button */
1894+
.tab-menu-btn::before {
1895+
content: '';
1896+
position: absolute;
1897+
top: 50%;
1898+
left: 50%;
1899+
transform: translate(-50%, -50%);
1900+
width: 48px;
1901+
height: 48px;
1902+
}
1903+
1904+
/* Touch-optimized styling for coarser pointers (e.g., smartphones & tablets) */
1905+
@media (pointer: coarse) {
1906+
.tab-bar {
1907+
height: 40px !important;
1908+
}
1909+
.tab-item {
1910+
height: 40px !important;
1911+
font-size: 14px !important;
1912+
padding: 0 10px 0 12px !important;
1913+
gap: 8px !important;
1914+
}
1915+
.tab-new-btn {
1916+
width: 32px !important;
1917+
height: 32px !important;
1918+
font-size: 18px !important;
1919+
}
1920+
.tab-menu-btn {
1921+
width: 30px !important;
1922+
height: 30px !important;
1923+
font-size: 18px !important;
1924+
}
1925+
.tab-close-btn {
1926+
width: 20px !important;
1927+
height: 20px !important;
1928+
font-size: 13px !important;
1929+
opacity: 0.8 !important;
1930+
}
1931+
}
1932+
18931933
.tab-item:hover .tab-menu-btn,
18941934
.tab-item.active .tab-menu-btn {
18951935
opacity: 0.65;

script.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5073,12 +5073,17 @@ document.addEventListener("DOMContentLoaded", function () {
50735073

50745074
initTabs();
50755075
if (loadGlobalState().syncScrollingEnabled === false) toggleSyncScrolling();
5076-
initEditorGeometry();
5077-
refreshEditorWidth();
50785076
updateMobileStats();
50795077
updateFindHighlights();
50805078
syncHighlightScroll();
50815079

5080+
// Defer DOM geometry measurement until after FCP/LCP critical paint path
5081+
setTimeout(function() {
5082+
initEditorGeometry();
5083+
refreshEditorWidth();
5084+
scheduleLineNumberUpdate();
5085+
}, 100);
5086+
50825087
// Initialize resizer - Story 1.3
50835088
initResizer();
50845089
function constrainFloatingPanelPosition() {
@@ -5105,14 +5110,18 @@ document.addEventListener("DOMContentLoaded", function () {
51055110
lastFloatingTop = constrainedTop;
51065111
}
51075112

5113+
let resizeLayoutTimeout = null;
51085114
window.addEventListener('resize', () => {
5109-
initEditorGeometry();
5110-
refreshEditorWidth();
5111-
scheduleLineNumberUpdate();
5112-
if (window.innerWidth < 1080 && isFrDocked && isFindModalOpen) {
5113-
toggleFrDockMode(true);
5114-
}
5115-
constrainFloatingPanelPosition();
5115+
clearTimeout(resizeLayoutTimeout);
5116+
resizeLayoutTimeout = setTimeout(function() {
5117+
initEditorGeometry();
5118+
refreshEditorWidth();
5119+
scheduleLineNumberUpdate();
5120+
if (window.innerWidth < 1080 && isFrDocked && isFindModalOpen) {
5121+
toggleFrDockMode(true);
5122+
}
5123+
constrainFloatingPanelPosition();
5124+
}, 100);
51165125
});
51175126

51185127
// View Mode Button Event Listeners - Story 1.1

styles.css

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,46 @@ a:focus {
18901890
position: relative;
18911891
}
18921892

1893+
/* Touch Hitbox Expansion for Tab Menu Button */
1894+
.tab-menu-btn::before {
1895+
content: '';
1896+
position: absolute;
1897+
top: 50%;
1898+
left: 50%;
1899+
transform: translate(-50%, -50%);
1900+
width: 48px;
1901+
height: 48px;
1902+
}
1903+
1904+
/* Touch-optimized styling for coarser pointers (e.g., smartphones & tablets) */
1905+
@media (pointer: coarse) {
1906+
.tab-bar {
1907+
height: 40px !important;
1908+
}
1909+
.tab-item {
1910+
height: 40px !important;
1911+
font-size: 14px !important;
1912+
padding: 0 10px 0 12px !important;
1913+
gap: 8px !important;
1914+
}
1915+
.tab-new-btn {
1916+
width: 32px !important;
1917+
height: 32px !important;
1918+
font-size: 18px !important;
1919+
}
1920+
.tab-menu-btn {
1921+
width: 30px !important;
1922+
height: 30px !important;
1923+
font-size: 18px !important;
1924+
}
1925+
.tab-close-btn {
1926+
width: 20px !important;
1927+
height: 20px !important;
1928+
font-size: 13px !important;
1929+
opacity: 0.8 !important;
1930+
}
1931+
}
1932+
18931933
.tab-item:hover .tab-menu-btn,
18941934
.tab-item.active .tab-menu-btn {
18951935
opacity: 0.65;

0 commit comments

Comments
 (0)