From 15856574d767b2cf7f0e64e8c79f9dff988d1193 Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Tue, 29 Mar 2016 16:10:50 +0200 Subject: [PATCH] Add fade option to weather forecast. --- modules/weatherforecast/weatherforecast.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/weatherforecast/weatherforecast.js b/modules/weatherforecast/weatherforecast.js index a6ff08ef..47ac33db 100644 --- a/modules/weatherforecast/weatherforecast.js +++ b/modules/weatherforecast/weatherforecast.js @@ -18,6 +18,8 @@ Module.create({ animationSpeed: 1000, timeFormat: config.timeFormat, lang: config.language, + fade: true, + fadePoint: 0.25, // Start on 1/4th of the list. initialLoadDelay: 5000, // 5 seconds delay. This delay is used to keep the OpenWeather API happy. retryDelay: 2500, @@ -129,6 +131,21 @@ Module.create({ minTempCell.className = 'align-right min-temp'; row.appendChild(minTempCell); + + if (this.config.fade && this.config.fadePoint < 1) { + if (this.config.fadePoint < 0) { + this.config.fadePoint = 0; + } + var startingPoint = this.forecast.length * this.config.fadePoint; + var steps = this.forecast.length - startingPoint; + if (f >= startingPoint) { + var currentStep = f - startingPoint; + row.style.opacity = 1 - (1 / steps * currentStep); + } + } + + + }