Is there a way to have a screen saver connected to Wix, so that I am saving our touch screen TV from shadowing
Here’s something pretty rudimentary to get your ideas flowing but will require you to create multiple event handlers sadly.
If you use setTimeout and clearTimeout with appropriate element actions (onClick, onViewportEnter, onMousenter etc.), or starting some other action like running a video, then you can create an event that will start, reset and end a screensaver using functions similar to below. Then you have an element (I used a box) that is collapsed until the timer fires and the box is expanded.
wix doesn’t currently support the onMouseMove event or an onScroll event in wix-window or on $w that you could use to reset a timeout timer. Hence the need to be creative with other provided event handlers.
This seems like it would be a good idea for a new wix-api wix-screensaver!
export function page1_click(event, $w) {
//Add your code for this event here:
console.log(“page_1 Clicked”);
resetScreenSaverTimer();
}
export function header1_viewportLeave(event, $w) {
//Add your code for this event here:
console.log(“header scrolled out of the view”);
resetScreenSaverTimer();
}
export function header1_viewportEnter(event, $w) {
//Add your code for this event here:
console.log(“header scrolled into view”);
resetScreenSaverTimer();
}
export function footer1_viewportEnter(event, $w) {
//Add your code for this event here:
console.log(“footer scrolled into view”);
resetScreenSaverTimer();
}
export function footer1_viewportLeave(event, $w) {
//Add your code for this event here:
console.log(“footer scrolled out of the view”);
resetScreenSaverTimer();
}
… (add other handlers)
function startScreenSaverTimer() {
console.log(‘Screensaver time started’);
timer = setTimeout(() => {
$w(‘#screenSaver’).expand();
}, 20000);
}
function stopScreensaverTimer() {
clearTimeout(timer);
}
function resetScreenSaverTimer() {
console.log(‘reset Screensaver’);
stopScreensaverTimer();
// Restart screen saver
startScreenSaverTimer();
}
export function screenSaver_click(event, $w) {
//Runs when the screen saver element is clicked
$w(‘#screenSaver’).collapse();
startScreenSaverTimer();
}