From 14ee21c93138d8b352d14c2b38a5a3c6012184a2 Mon Sep 17 00:00:00 2001 From: Elizabeth Cray Date: Fri, 23 Jun 2023 17:12:10 -0400 Subject: [PATCH] Adjustable Fade Delay --- project.json | 24 +++++++++++++++++------- scripts/scene.js | 20 +++++++++++++++++++- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/project.json b/project.json index d2eeeb7..4db19cb 100644 --- a/project.json +++ b/project.json @@ -32,11 +32,10 @@ { "fraction" : false, "index" : 4, - "max" : 1440, + "max" : 120, "min" : 0, "order" : 104, - "step" : 1, - "text" : "Change Every (minutes)", + "text" : "Duration (m)", "type" : "slider", "value" : 0 }, @@ -44,15 +43,26 @@ { "fraction" : true, "index" : 3, - "max" : 60, - "min" : 0.1, + "max" : 59, + "min" : 0.5, "order" : 103, "precision" : 2, - "step" : 0.1, - "text" : "Change Every (seconds)", + "step" : 0.5, + "text" : "Duration (s)", "type" : "slider", "value" : 30 }, + "transition_time" : + { + "fraction" : false, + "index" : 5, + "max" : 60, + "min" : 0, + "order" : 105, + "text" : "Fade Delay (s)", + "type" : "slider", + "value" : 5 + }, "uri" : { "index" : 1, diff --git a/scripts/scene.js b/scripts/scene.js index 318194b..c15f400 100644 --- a/scripts/scene.js +++ b/scripts/scene.js @@ -1,5 +1,4 @@ // TODO: -// + Add adjustable timing // - Add random timing option @@ -46,6 +45,20 @@ let loadMime = () => { }) } +let adjustTransition = () => { + let transition = localStorage.getItem('transition_time') + console.log(`%cTransition Time: ${transition}s`, 'color: #EBCB8B; font-family: monospace;') + if (transition == null) { + transition = 5 + } + let wallpaper = document.getElementById('wallpaper') + wallpaper.style.transition = `background ${transition}s linear` + wallpaper.style.webkitTransition = `background ${transition}s linear` + wallpaper.style.mozTransition = `background ${transition}s linear` + wallpaper.style.oTransition = `background ${transition}s linear` + wallpaper.style.msTransition = `background ${transition}s linear` +} + let urlExists = (url, callback) => { var request = new XMLHttpRequest() request.open('GET', url, true) @@ -109,6 +122,7 @@ let dumpStorage = () => { console.log(' System:' + localStorage.getItem('systemId')) console.log(' Socket:' + localStorage.getItem('socket')) console.log(' Slide Delay:' + localStorage.getItem('timeout_m') + "m " + localStorage.getItem('timeout_s') + "s") + console.log(' Fade Delay:' + localStorage.getItem('transition_time')) console.log(' Wallpapers:') console.log(("%c "+localStorage.getItem('wallpapers')), "color: #A3BE8C; font-family: monospace; font-size: 8px;") } @@ -229,6 +243,10 @@ window.wallpaperPropertyListener = { if (properties.timeout_m) { localStorage.setItem('timeout_m', properties.timeout_m.value) } + if (properties.transition_time) { + localStorage.setItem('transition_time', properties.transition_time.value) + adjustTransition() + } if (properties.systemid) { localStorage.setItem('systemId', properties.systemid.value) }