I am strugling a bit with this code in a HTML template
Code: Select all
function update(str){
x = JSON.parse(str);
Object.keys(x).forEach(function(key) {
try{
if (document.getElementById(key).innerHTML !== x[key]){
daID= document.getElementById(key);
var tl = new TimelineMax();
tl.to(daID, 0.5, {opacity:0}).add( function(){ daID.innerHTML= x[key] }).to(daID, 0.5, {opacity:1} ) ;
tl.play
}
}
catch(err){
console.log(err);
}
});
};
Code: Select all
update('{"f0":"a","f1":"b","f2":"c"}')
if i update again "f1" will change and updating again makes "f0" change.
goal is to have a
fadeout all changed fields => change all changed fields => fadein all changed fields
effect when updating
i know the coase (the for loop is going to fast ) but i have no clue how to fix it ;)