Skip to content

Commit

Permalink
Merge pull request #16533 from johndoknjas/chart-icons-mobile-phones
Browse files Browse the repository at this point in the history
Chart icon positions on mobile phones
  • Loading branch information
ornicar authored Dec 10, 2024
2 parents e8eb025 + 775abfb commit ffb26fe
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ui/lobby/src/view/realTime/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { bind } from 'common/snabbdom';
import { h, type VNode } from 'snabbdom';
import type { Hook } from '../../interfaces';
import perfIcons from 'common/perfIcons';
import { memoize } from 'common';

const percents = (v: number) => v + '%';

Expand All @@ -30,9 +31,15 @@ const clockX = (dur: number) => {
return Math.round((durLog(Math.min(clockMax, dur || clockMax)) / durLog(clockMax)) * 100);
};

const iconTranslateAmts: () => [number, number] = memoize<[number, number]>(() => {
const chart = document.querySelector('.hooks__chart') as HTMLElement;
const fontSize = parseFloat(window.getComputedStyle(chart).fontSize);
return [(fontSize / chart.clientWidth) * 95, (fontSize / chart.clientHeight) * 75];
});

function renderPlot(ctrl: LobbyController, hook: Hook) {
const bottom = Math.max(0, ratingY(hook.rating) - 2),
left = Math.max(0, clockX(hook.t) - 2),
const bottom = Math.max(0, ratingY(hook.rating) - iconTranslateAmts()[1]),
left = Math.max(0, clockX(hook.t) - iconTranslateAmts()[0]),
klass = [
hook.id,
'plot.new',
Expand Down

0 comments on commit ffb26fe

Please sign in to comment.