openvibers/openvibe.live Commits
Hero stats: measure the settled height before animating the swap
Changes
@@@ -5130,7 +5130,7 @@ curl -s https://openvibe.media/live/@Goosely/chat-insight.json | jq ".chat_insig<script src="/live-notify.js?v=3" defer></script><script src="/js/ov-skeleton.js?v=1" defer></script><script src="/js/ov-odometer.js?v=3" defer></script>--<script src="/js/app.js?v=155" defer></script>++<script src="/js/app.js?v=156" defer></script><script src="/js/stream-player.js?v=22" defer></script><script src="/js/stream-pip.js?v=1" defer></script><script src="/js/chat-shared.js?v=3" defer></script>@@@ -1534,11 +1534,15 @@ function renderHeroStats(stats) {};btn.addEventListener('click', () => {++ // The board's chips start showing "0" and count up, and a chip reading "70,172" is taller++ // than one reading "0" once its label wraps — so the height measured at click time was++ // several hundred pixels short of where the board actually settles, and the animation++ // finished with a jump. Write the final text first, measure, animate, then count up from++ // zero over the top of it.++ const pending = full.hidden ? [...full.querySelectorAll('.hero-stat-num:not([data-counted])')] : [];++ pending.forEach(el => { el.textContent = _heroStatFmt(parseInt(el.dataset.n, 10) || 0); });swap();-- // Count the numbers up the first time they are actually looked at.-- if (!full.hidden) full.querySelectorAll('.hero-stat-num:not([data-counted])').forEach(el => {-- el.setAttribute('data-counted', '1'); _heroCountUp(el, parseInt(el.dataset.n, 10) || 0);-- });++ pending.forEach(el => { el.setAttribute('data-counted', '1'); _heroCountUp(el, parseInt(el.dataset.n, 10) || 0); });});wrap.querySelectorAll('.hero-stat-strip .hero-stat-num').forEach(el => {el.setAttribute('data-counted', '1');
@@ -5130,7 +5130,7 @@ curl -s https://openvibe.media/live/@Goosely/chat-insight.json | jq ".chat_insig
@@ -5130,7 +5130,7 @@ curl -s https://openvibe.media/live/@Goosely/chat-insight.json | jq ".chat_insig
<script src="/live-notify.js?v=3" defer></script>
<script src="/live-notify.js?v=3" defer></script>
<script src="/js/ov-skeleton.js?v=1" defer></script>
<script src="/js/ov-skeleton.js?v=1" defer></script>
<script src="/js/ov-odometer.js?v=3" defer></script>
<script src="/js/ov-odometer.js?v=3" defer></script>
-<script src="/js/app.js?v=155" defer></script>
+<script src="/js/app.js?v=156" defer></script>
<script src="/js/stream-player.js?v=22" defer></script>
<script src="/js/stream-player.js?v=22" defer></script>
<script src="/js/stream-pip.js?v=1" defer></script>
<script src="/js/stream-pip.js?v=1" defer></script>
<script src="/js/chat-shared.js?v=3" defer></script>
<script src="/js/chat-shared.js?v=3" defer></script>
@@ -1534,11 +1534,15 @@ function renderHeroStats(stats) {
@@ -1534,11 +1534,15 @@ function renderHeroStats(stats) {
};
};
btn.addEventListener('click', () => {
btn.addEventListener('click', () => {
+ // The board's chips start showing "0" and count up, and a chip reading "70,172" is taller
+ // than one reading "0" once its label wraps — so the height measured at click time was
+ // several hundred pixels short of where the board actually settles, and the animation
+ // finished with a jump. Write the final text first, measure, animate, then count up from
+ // zero over the top of it.
+ const pending = full.hidden ? [...full.querySelectorAll('.hero-stat-num:not([data-counted])')] : [];
+ pending.forEach(el => { el.textContent = _heroStatFmt(parseInt(el.dataset.n, 10) || 0); });
swap();
swap();
- // Count the numbers up the first time they are actually looked at.
- if (!full.hidden) full.querySelectorAll('.hero-stat-num:not([data-counted])').forEach(el => {
- el.setAttribute('data-counted', '1'); _heroCountUp(el, parseInt(el.dataset.n, 10) || 0);
- });
+ pending.forEach(el => { el.setAttribute('data-counted', '1'); _heroCountUp(el, parseInt(el.dataset.n, 10) || 0); });
});
});
wrap.querySelectorAll('.hero-stat-strip .hero-stat-num').forEach(el => {
wrap.querySelectorAll('.hero-stat-strip .hero-stat-num').forEach(el => {
el.setAttribute('data-counted', '1');
el.setAttribute('data-counted', '1');