mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-18 17:49:31 -07:00
scroll triggers properly on red background
This commit is contained in:
@@ -19,8 +19,6 @@ let hazardData;
|
|||||||
// start drawing conditions
|
// start drawing conditions
|
||||||
// reset starts from the first item in the text scroll list
|
// reset starts from the first item in the text scroll list
|
||||||
const start = () => {
|
const start = () => {
|
||||||
// store see if the context is new
|
|
||||||
|
|
||||||
// set up the interval if needed
|
// set up the interval if needed
|
||||||
if (!interval) {
|
if (!interval) {
|
||||||
interval = setInterval(incrementInterval, 500);
|
interval = setInterval(incrementInterval, 500);
|
||||||
@@ -74,8 +72,10 @@ const drawScreen = async () => {
|
|||||||
const thisScreen = screens[screenIndex](data);
|
const thisScreen = screens[screenIndex](data);
|
||||||
|
|
||||||
// update classes on the scroll area
|
// update classes on the scroll area
|
||||||
elemForEach('.weather-display .scroll .fixed', (elem) => {
|
elemForEach('.weather-display .scroll', (elem) => {
|
||||||
elem.classList.forEach((cls) => { if (cls !== 'fixed') elem.classList.remove(cls); });
|
elem.classList.forEach((cls) => { if (cls !== 'scroll') elem.classList.remove(cls); });
|
||||||
|
// no scroll on progress
|
||||||
|
if (elem.parentElement.id === 'progress-html') return;
|
||||||
thisScreen?.classes?.forEach((cls) => elem.classList.add(cls));
|
thisScreen?.classes?.forEach((cls) => elem.classList.add(cls));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -159,9 +159,6 @@ const drawCondition = (text) => {
|
|||||||
elem.innerHTML = text;
|
elem.innerHTML = text;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
|
||||||
start();
|
|
||||||
});
|
|
||||||
|
|
||||||
// store the original number of screens
|
// store the original number of screens
|
||||||
const originalScreens = screens.length;
|
const originalScreens = screens.length;
|
||||||
@@ -211,7 +208,23 @@ const drawScrollCondition = (screen) => {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const parseMessage = (event) => {
|
||||||
|
if (event?.data?.type === 'current-weather-scroll') {
|
||||||
|
if (event.data?.method === 'start') start();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// add event listener for start message
|
||||||
|
window.addEventListener('message', parseMessage);
|
||||||
|
|
||||||
window.CurrentWeatherScroll = {
|
window.CurrentWeatherScroll = {
|
||||||
addScreen,
|
addScreen,
|
||||||
reset,
|
reset,
|
||||||
|
start,
|
||||||
|
};
|
||||||
|
|
||||||
|
export {
|
||||||
|
addScreen,
|
||||||
|
reset,
|
||||||
|
start,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ class WeatherDisplay {
|
|||||||
// clean up the first-run flag in screen index
|
// clean up the first-run flag in screen index
|
||||||
if (this.screenIndex < 0) this.screenIndex = 0;
|
if (this.screenIndex < 0) this.screenIndex = 0;
|
||||||
if (this.okToDrawCurrentDateTime) this.drawCurrentDateTime();
|
if (this.okToDrawCurrentDateTime) this.drawCurrentDateTime();
|
||||||
|
if (this.okToDrawCurrentConditions) postMessage({ type: 'current-weather-scroll', method: 'start' });
|
||||||
}
|
}
|
||||||
|
|
||||||
finishDraw() {
|
finishDraw() {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -116,7 +116,8 @@
|
|||||||
width: 640px;
|
width: 640px;
|
||||||
height: 70px;
|
height: 70px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin-top: 10px;
|
margin-top: 3px;
|
||||||
|
padding-top: 7px;
|
||||||
|
|
||||||
&.hazard {
|
&.hazard {
|
||||||
background-color: rgb(112, 35, 35);
|
background-color: rgb(112, 35, 35);
|
||||||
|
|||||||
Reference in New Issue
Block a user