Skip to content

Commit

Permalink
Merge pull request #16970 from lichess-org/nico-shitcoin-wallet
Browse files Browse the repository at this point in the history
fix bar flicker on android brave
  • Loading branch information
ornicar authored Feb 13, 2025
2 parents 49e3457 + 467e46b commit 3f75795
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
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

0 comments on commit 3f75795

Please sign in to comment.