This commit is contained in:
salam committed 2026-06-15 11:19:14 +02:00
1 parent 5a7e118f80
commit 146c144c87
2 files changed
+13 -23

No files matched your search

+6 -12
View File
@@ -104,19 +104,13 @@ class StatsMedianAverage extends StatsOverviewWidget
else
$value_away = 0;
// dd($value_home);
if ($data['similar_past_matches'] != 'none')
$fixtotwo = true;
else
$fixtotwo = false;
return [
Stat::make('Number of events', new HtmlString('<div id="number-of-events">' . $total_home . '</div>'))->extraAttributes(['x-init' => "animate('number-of-events', $total_home)"]),
Stat::make('Average ' . $statistic_type, self::template('avhome', 'avaway', $home_team, $away_team))->extraAttributes(['x-init' => "animate('avhome', $value_home); animate('avaway', $value_away)"]),
Stat::make('Median ' . $statistic_type, self::template('mehome', 'meaway', $home_team, $away_team))->extraAttributes(['x-init' => "animate('mehome', $median_home); animate('meaway', $median_away)"]),
Stat::make($data['similar_past_matches'] != 'none' ? '1' : 'Win: ' . $data['results']['w'], new HtmlString('<div id="number-of-win">' . $win . '</div>'))->extraAttributes(['x-init' => "animate('number-of-win', $win, 500, $fixtotwo)"]),
Stat::make($data['similar_past_matches'] != 'none' ? 'X' : 'Draw: ' . $data['results']['d'], new HtmlString('<div id="number-of-draw">' . $draw . '</div>'))->extraAttributes(['x-init' => "animate('number-of-draw', $draw, 500, $fixtotwo)"]),
Stat::make($data['similar_past_matches'] != 'none' ? '2' : 'Lost: ' . $data['results']['l'], new HtmlString('<div id="number-of-lost">' . $lost . '</div>'))->extraAttributes(['x-init' => "animate('number-of-lost', $lost, 500, $fixtotwo)"]),
Stat::make('Number of events', new HtmlString('<div id="number-of-events">' . $total_home . '</div>'))->extraAttributes(['x-init' => "animate('number-of-events', $total_home, 0)"]),
Stat::make('Average ' . $statistic_type, self::template('avhome', 'avaway', $home_team, $away_team))->extraAttributes(['x-init' => "animate('avhome', $value_home); animate('avaway', $value_away, 0)"]),
Stat::make('Median ' . $statistic_type, self::template('mehome', 'meaway', $home_team, $away_team))->extraAttributes(['x-init' => "animate('mehome', $median_home); animate('meaway', $median_away, 0)"]),
Stat::make($data['similar_past_matches'] != 'none' ? '1' : 'Win: ' . $data['results']['w'], new HtmlString('<div id="number-of-win">' . $win . '</div>'))->extraAttributes(['x-init' => "animate('number-of-win', $win, 1)"]),
Stat::make($data['similar_past_matches'] != 'none' ? 'X' : 'Draw: ' . $data['results']['d'], new HtmlString('<div id="number-of-draw">' . $draw . '</div>'))->extraAttributes(['x-init' => "animate('number-of-draw', $draw, 1)"]),
Stat::make($data['similar_past_matches'] != 'none' ? '2' : 'Lost: ' . $data['results']['l'], new HtmlString('<div id="number-of-lost">' . $lost . '</div>'))->extraAttributes(['x-init' => "animate('number-of-lost', $lost, 1)"]),
];
}
+7 -11
View File
@@ -1,4 +1,4 @@
function animate(element, end, duration = 500, fixtotwo) {
function animate(element, end, fixtotwo) {
console.log(element, end);
var element = document.getElementById(element);
@@ -10,7 +10,7 @@ function animate(element, end, duration = 500, fixtotwo) {
const updateCount = (currentTime) => {
const elapsedTime = currentTime - startTime;
let progress = elapsedTime / duration;
let progress = elapsedTime / 500;
// Clamp progress to ensure it doesn't overshoot
if (progress > 1) progress = 1;
@@ -21,15 +21,11 @@ function animate(element, end, duration = 500, fixtotwo) {
// Calculate current value and round to integer
const currentCount = Math.round(end * easedProgress * 100) / 100;
element.innerHTML = currentCount.toFixed(2);
// if (fixtotwo) {
// console.log("fix2");
// element.innerHTML = currentCount.toFixed(2);
// } else {
// console.log("fixNone");
// element.innerHTML = currentCount;
// }
if (fixtotwo) {
element.innerHTML = currentCount.toFixed(2);
} else {
element.innerHTML = currentCount;
}
if (progress < 1) {
requestAnimationFrame(updateCount);