Add resize event listener to regenerate spectrum
parent
690368c118
commit
ef9848b4ea
|
@ -86,6 +86,8 @@ WhatColorIsIt.prototype.spectrum = function(today) {
|
|||
var tomorrow = today + 86400000;
|
||||
var increment = (tomorrow - today) / this.spectrumDiv.offsetWidth;
|
||||
|
||||
this.spectrumDiv.innerHTML = '';
|
||||
|
||||
for(var i = today; i < tomorrow; i += increment) {
|
||||
color = document.createElement('div');
|
||||
color.style.background = this.toColor(new Date(i));
|
||||
|
@ -117,6 +119,13 @@ WhatColorIsIt.prototype.process = function(d) {
|
|||
|
||||
WhatColorIsIt.prototype.run = function() {
|
||||
this.spectrum(Date.today());
|
||||
window.addEventListener('resize', function() {
|
||||
if(typeof resizewait != 'undefined') {
|
||||
clearTimeout(resizewait);
|
||||
}
|
||||
resizewait = setTimeout(function() { this.spectrum(Date.today()); }.bind(this), 200);
|
||||
}.bind(this));
|
||||
|
||||
this.start();
|
||||
};
|
||||
WhatColorIsIt.prototype.start = function() {
|
||||
|
|
Loading…
Reference in New Issue