Add fade option to weather forecast.

This commit is contained in:
Michael Teeuw 2016-03-29 16:10:50 +02:00
parent c09f8e97f7
commit 15856574d7

View File

@ -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);
}
}
}