Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bar flicker on android brave #16970

Merged
merged 4 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions ui/common/src/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ export const isTouchDevice = (): boolean => !hasMouse(); // prefer isTouchDevice

export const isMobile = (): boolean => isAndroid() || isIos();

export const isAndroid = (): boolean => /Android/.test(navigator.userAgent);
export const isAndroid: () => boolean = memoize(() => /Android/.test(navigator.userAgent));

export const isIos: () => boolean = memoize<boolean>(
() => /iPhone|iPod/.test(navigator.userAgent) || isIPad(),
);
export const isIos: () => boolean = memoize(() => /iPhone|iPod/.test(navigator.userAgent) || isIPad());

export const isIPad = (): boolean =>
navigator?.maxTouchPoints > 2 && /iPad|Macintosh/.test(navigator.userAgent);
Expand Down
6 changes: 5 additions & 1 deletion ui/round/src/clock/clockView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { ClockElements, ClockController } from './clockCtrl';
import type { Hooks } from 'snabbdom';
import { looseH as h, type VNode, bind } from 'common/snabbdom';
import type { Position } from '../interfaces';
import { isAndroid, isCol1 } from 'common/device';

export function renderClock(ctrl: RoundController, player: Player, position: Position): VNode {
const clock = ctrl.clock!,
Expand Down Expand Up @@ -113,7 +114,10 @@ function showBar(ctrl: RoundController, color: Color) {

export function updateElements(clock: ClockController, els: ClockElements, millis: Millis): void {
if (els.time) els.time.innerHTML = formatClockTime(millis, clock.showTenths(millis), true, clock.opts.nvui);
if (els.bar) els.bar.style.transform = 'scale(' + clock.timeRatio(millis) + ',1)';
// 12/02/2025 Brave 1.74.51 android flickers the bar oninline transforms, even though .bar is display: none
if (els.bar)
if (!isAndroid() || !isCol1() || window.getComputedStyle(els.bar).display === 'block')
els.bar.style.transform = 'scale(' + clock.timeRatio(millis) + ',1)';
if (els.clock) {
const cl = els.clock.classList;
if (millis < clock.emergMs) cl.add('emerg');
Expand Down