]> git.sesse.net Git - ultimatescore/commitdiff
Factor out fading.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 20 Oct 2017 18:12:30 +0000 (20:12 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 20 Oct 2017 18:12:30 +0000 (20:12 +0200)
carousel.js

index a3628913cbb6f32e2c2b29294af29489b2545ecc..42639952243dd138936814744ad25e3d2c5ca5bf 100644 (file)
@@ -319,14 +319,12 @@ var display_group = function(response, group_name) {
                addtd(tr, "gd", teams[i].gd.toString().replace(/-/, '−'));
                addtd(tr, "pts", teams[i].pts);
 
-               tr.style = "-webkit-animation: fade-in 1.0s ease; -webkit-animation-delay: " + 0.25 * (row_num++) + "s; -webkit-animation-fill-mode: both;";
                carousel.appendChild(tr);
        }
 
        if (tiebreakers.length > 0) {
                var tie_tr = document.createElement("tr");
                tie_tr.className = "footer";
-               tie_tr.style = "-webkit-animation: fade-in 2.0s ease; -webkit-animation-delay: " + 0.25 * (row_num++) + "s; -webkit-animation-fill-mode: both;";
                var td = document.createElement("td");
                td.appendChild(document.createTextNode("Tiebreaks applied: " + tiebreakers.join(', ')));
                td.setAttribute("colspan", "5");
@@ -336,16 +334,29 @@ var display_group = function(response, group_name) {
 
        var footer_tr = document.createElement("tr");
        footer_tr.className = "footer";
-       footer_tr.style = "-webkit-animation: fade-in 2.0s ease; -webkit-animation-delay: " + 0.25 * (row_num++) + "s; -webkit-animation-fill-mode: both;";
        var td = document.createElement("td");
        td.appendChild(document.createTextNode("www.trondheimfrisbeeklubb.no | #trøndisk"));
        td.setAttribute("colspan", "5");
        footer_tr.appendChild(td);
        carousel.appendChild(footer_tr);
 
+       fade_in_rows(carousel);
+
        carousel.style.display = 'table';
 };
 
+var fade_in_rows = function(table)
+{
+       var trs = table.getElementsByTagName("tr");
+       for (var i = 1; i < trs.length; ++i) {  // The header already has its own fade-in.
+               if (trs[i].className === "footer") {
+                       trs[i].style = "-webkit-animation: fade-in 1.0s ease; -webkit-animation-delay: " + (0.25 * i) + "s; -webkit-animation-fill-mode: both;";
+               } else {
+                       trs[i].style = "-webkit-animation: fade-in 2.0s ease; -webkit-animation-delay: " + (0.25 * i) + "s; -webkit-animation-fill-mode: both;";
+               }
+       }
+};
+
 // Stream schedule
 var display_stream_schedule = function(response, group_name) {
        var teams = parse_teams_from_spreadsheet(response);
@@ -398,10 +409,12 @@ var display_stream_schedule_parsed = function(teams, games) {
                        addth(tr, "streamtime", games[i].streamtime);
                }
 
-               tr.style = "-webkit-animation: fade-in 1.0s ease; -webkit-animation-delay: " + 0.25 * (row_num++) + "s; -webkit-animation-fill-mode: both;";
+               row_num++;
                carousel.appendChild(tr);
        }
 
+       fade_in_rows(carousel);
+
        carousel.style.display = 'table';
 };