Skip to content

Commit 43be610

Browse files
committed
Trim report reveal code size
1 parent 347e1c3 commit 43be610

1 file changed

Lines changed: 9 additions & 20 deletions

File tree

packages/apk-webui/src/app.js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4582,25 +4582,29 @@ function revealReportHeroAfterAnalysis(report) {
45824582
return;
45834583
}
45844584

4585-
const revealToken = runtime.reportRevealToken + 1;
4586-
runtime.reportRevealToken = revealToken;
4585+
const revealToken = ++runtime.reportRevealToken;
45874586
const reveal = () => {
45884587
if (
45894588
runtime.reportRevealToken !== revealToken ||
45904589
state.appMode !== "analyze" ||
45914590
state.report !== report ||
45924591
elements.resultView.hidden ||
45934592
!target.isConnected ||
4594-
!target.children.length ||
4595-
isReportHeroComfortablyVisible(target)
4593+
!target.children.length
45964594
) {
45974595
return;
45984596
}
45994597

4598+
const rect = target.getBoundingClientRect();
4599+
const viewportHeight = window.innerHeight || document.documentElement.clientHeight || 0;
4600+
const topComfort = Number.parseFloat(getComputedStyle(target).scrollMarginTop) || 0;
4601+
if (rect.top >= topComfort && rect.bottom <= viewportHeight - 24) {
4602+
return;
4603+
}
4604+
46004605
target.scrollIntoView({
46014606
behavior: isAppPowerConstrained() ? "auto" : "smooth",
46024607
block: "start",
4603-
inline: "nearest",
46044608
});
46054609
};
46064610

@@ -4609,21 +4613,6 @@ function revealReportHeroAfterAnalysis(report) {
46094613
});
46104614
}
46114615

4612-
function isReportHeroComfortablyVisible(target) {
4613-
const rect = target.getBoundingClientRect();
4614-
const viewportHeight = window.innerHeight || document.documentElement.clientHeight || 0;
4615-
if (!Number.isFinite(rect.top) || !Number.isFinite(rect.bottom) || viewportHeight <= 0) {
4616-
return false;
4617-
}
4618-
4619-
const style = getComputedStyle(document.documentElement);
4620-
const topbarHeight = Number.parseFloat(style.getPropertyValue("--topbar-height")) || 0;
4621-
const topbarGap = Number.parseFloat(style.getPropertyValue("--topbar-gap-after")) || 0;
4622-
const topComfort = topbarHeight + topbarGap;
4623-
const bottomComfort = 24;
4624-
return rect.top >= topComfort && rect.bottom <= viewportHeight - bottomComfort;
4625-
}
4626-
46274616
function updateTabs() {
46284617
updateTabButtonsView(elements, state.activeTab);
46294618
clearTabPendingButtons();

0 commit comments

Comments
 (0)