wip
This commit is contained in:
1 parent
5a7e118f80
commit
146c144c87
2 files changed
+12
-22
No files matched your search
@@ -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)"]),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
if (fixtotwo) {
|
||||
element.innerHTML = currentCount.toFixed(2);
|
||||
|
||||
// if (fixtotwo) {
|
||||
// console.log("fix2");
|
||||
// element.innerHTML = currentCount.toFixed(2);
|
||||
// } else {
|
||||
// console.log("fixNone");
|
||||
// element.innerHTML = currentCount;
|
||||
// }
|
||||
} else {
|
||||
element.innerHTML = currentCount;
|
||||
}
|
||||
|
||||
if (progress < 1) {
|
||||
requestAnimationFrame(updateCount);
|
||||
|
||||
Reference in new issue
Block a user