Skip to content

Commit

Permalink
feat: add variable control height with zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
sanoojes committed Jun 26, 2024
1 parent bfa61cd commit 4be01ab
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions hazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@
document.documentElement.style.setProperty("--control-width", `${width}px`);
}

async function setMainWindowControlHeight(height) {
await Spicetify.CosmosAsync.post("sp://messages/v1/container/control", {
type: "update_titlebar",
height: height,
});
}

function calculateBrowserZoom() {
const viewportWidth = window.innerWidth;
const windowWidth = window.outerWidth;
Expand Down Expand Up @@ -205,12 +212,21 @@
document.querySelector(".global-nav") ||
document.querySelector(".Root__globalNav");

const baseHeight = isGlobalNav ? 64 : 40;
const baseHeight = isGlobalNav ? 64 : 42;
const baseWidth = 135;
const constant = 0.912872807;

const normalZoom = calculateBrowserZoom();
const inverseZoom = calculateInverseBrowserZoom();

const finalControlHeight = Math.round(
(normalZoom ** constant * 100) / 100 - (isGlobalNav ? 3 : 25)
);

console.log(finalControlHeight);

await setMainWindowControlHeight(finalControlHeight);

const paddingStart = calculateScaledPx(64, inverseZoom, 1);
const paddingEnd = calculateScaledPx(baseWidth, inverseZoom, 1);

Expand All @@ -225,12 +241,7 @@
`;
}
if (Spicetify.Platform.PlatformData.os_name === "windows" || "Windows") {
const transparentControlHeight = calculateScaledPx(
baseHeight,
inverseZoom,
1
);

const transparentControlHeight = baseHeight;
const transparentControlWidth = calculateScaledPx(
baseWidth,
inverseZoom,
Expand Down

0 comments on commit 4be01ab

Please sign in to comment.