From 1ae2f937a63c961660b0070bae5e4300e0f462e6 Mon Sep 17 00:00:00 2001 From: Gigi Date: Tue, 26 Apr 2022 17:46:05 +0200 Subject: [PATCH] feat: return to original color --- index.html | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index d6d75a2..e85e20a 100644 --- a/index.html +++ b/index.html @@ -13,10 +13,12 @@ qtip: '/js/jquery.qtip.min.js' $(function () { // Colors - var cOrange = '#F2A900'; - var cGray = '#333'; - var cDarkOrange = '#735000'; - var cDarkWhite = '#BBB'; + const cOrange = '#F2A900'; + const cGray = '#333'; + const cDarkOrange = '#735000'; + const cDarkWhite = '#BBB'; + + var pathColors = []; // initialize tooltips $.fn.qtip.defaults.style.classes = 'ui-tooltip-bootstrap'; @@ -50,7 +52,7 @@ qtip: '/js/jquery.qtip.min.js' path.attr('fill', Math.random() < 0.5 ? cDarkOrange : cDarkWhite ); }, mouseleave: function (d, path) { - path.animate({ fill: cGray }, 1000); // TODO: return to original color + path.animate({ fill: pathColors[d.iso] }, 1000); }, click: function (d, path) { console.log(d.iso); @@ -73,6 +75,7 @@ qtip: '/js/jquery.qtip.min.js' return c.alpha3; }); var isOrangeCountry = orangeCountryCodes.includes(data.iso) + pathColors[data.iso] = isOrangeCountry ? cOrange : cGray; return isOrangeCountry ? cOrange : cGray; }); }