sky logic

This commit is contained in:
Miodec 2023-02-23 19:55:07 +01:00
parent 0e164d3492
commit f990d8432c
2 changed files with 29 additions and 1 deletions

View file

@ -106,6 +106,16 @@ function updateBreakpoint(noReinstate = false): void {
}
}
function updateBreakpoint2(): void {
if (choice !== "pw") return;
if (window.innerWidth > 1330) {
PW.updateSky(true);
} else {
PW.updateSky(false);
}
}
export async function refreshVisible(): Promise<void> {
if (choice === "eg") {
await EG.refreshVisible();
@ -245,10 +255,12 @@ export function destroyResult(): void {
const debouncedMarginUpdate = debounce(100, updateVerticalMargin);
const debouncedBreakpointUpdate = debounce(100, updateBreakpoint);
const debouncedBreakpoint2Update = debounce(100, updateBreakpoint2);
$(window).on("resize", () => {
debouncedMarginUpdate();
debouncedBreakpointUpdate();
debouncedBreakpoint2Update();
});
ConfigEvent.subscribe((event, value) => {
@ -270,6 +282,7 @@ BannerEvent.subscribe(() => {
$(document).ready(() => {
updateBreakpoint(true);
updateBreakpoint2();
});
window.onerror = function (error): void {

View file

@ -131,7 +131,11 @@ function getUnits(): unknown {
const toReturn = [];
for (const unit of units) {
if (document.querySelector(`#${unit.selectorId}`)) {
const isSky = unit.type === "sky_atf";
if (
document.querySelector(`#${unit.selectorId}`) &&
(!isSky || (isSky && showSky))
) {
toReturn.push(unit);
}
}
@ -176,3 +180,14 @@ export function setMobile(tf: boolean): void {
if (!rampReady) return;
ramp.setMobile(tf);
}
let showSky = false;
export function updateSky(visible: boolean): void {
showSky = visible;
if (showSky && !ramp.getUnits().includes("sky_atf")) {
ramp.addUnits(getUnits()).then(() => {
ramp.displayUnits();
});
}
}