diff options
| author | RblSb <msrblsb@gmail.com> | 2020-03-11 07:18:33 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2020-03-11 07:18:33 +0300 |
| commit | 43d38010b20ca15c1aa909a578afeb5edd8c8bd3 (patch) | |
| tree | 6e2c944cd3a94cf15f55e560ff664bd0860db1b0 /src/client/Buttons.hx | |
| parent | 1fb3e2de251f5f1d33a43cd13bc4ca6d3ae23c26 (diff) | |
Emotes lazy load
Diffstat (limited to 'src/client/Buttons.hx')
| -rw-r--r-- | src/client/Buttons.hx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/client/Buttons.hx b/src/client/Buttons.hx index b8e4a16..b5656e1 100644 --- a/src/client/Buttons.hx +++ b/src/client/Buttons.hx @@ -1,5 +1,6 @@ package client; +import js.html.ImageElement; import haxe.Timer; import js.html.KeyboardEvent; import js.html.InputElement; @@ -30,11 +31,16 @@ class Buttons { final smilesBtn = ge("#smilesbtn"); smilesBtn.onclick = e -> { - smilesBtn.classList.toggle("active"); final smilesWrap = ge("#smileswrap"); - if (smilesBtn.classList.contains("active")) - smilesWrap.style.display = "block"; + if (smilesWrap.children.length == 0) return; + final isActive = smilesBtn.classList.toggle("active"); + if (isActive) smilesWrap.style.display = "block"; else smilesWrap.style.display = "none"; + if (smilesWrap.firstElementChild.dataset.src == null) return; + for (child in smilesWrap.children) { + (cast child : ImageElement).src = child.dataset.src; + child.removeAttribute("data-src"); + } } ge("#clearchatbtn").onclick = e -> { |
