Skip to content

Commit 5d71945

Browse files
committed
Exclude Safari emoji fix above 1.25x zoom
1 parent d2dfb82 commit 5d71945

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

web_src/js/index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {initNotificationsTable, initNotificationCount} from './features/notifica
2525
import {initStopwatch} from './features/stopwatch.js';
2626
import {createCodeEditor, createMonaco} from './features/codeeditor.js';
2727
import {svg, svgs} from './svg.js';
28-
import {stripTags} from './utils.js';
28+
import {stripTags, mqBinarySearch} from './utils.js';
2929

3030
const {AppSubUrl, StaticUrlPrefix, csrf} = window.config;
3131

@@ -2407,6 +2407,19 @@ $(document).ready(async () => {
24072407
.attr('title', '');
24082408
});
24092409

2410+
// Undo Safari emoji glitch fix at high enough zoom levels
2411+
if (navigator.userAgent.match('Safari')) {
2412+
$(window).resize(() => {
2413+
const px = mqBinarySearch('width', 0, 4096, 1, 'px');
2414+
const em = mqBinarySearch('width', 0, 1024, 0.01, 'em');
2415+
if (em * 16 * 1.25 - px <= -1) {
2416+
$('body').addClass('safari-above125');
2417+
} else {
2418+
$('body').removeClass('safari-above125');
2419+
}
2420+
});
2421+
}
2422+
24102423
// Semantic UI modules.
24112424
$('.dropdown:not(.custom)').dropdown({
24122425
fullTextSearch: 'exact'

web_src/js/utils.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,16 @@ export function uniq(arr) {
2828
export function stripTags(text) {
2929
return text.replace(/<[^>]*>?/gm, '');
3030
}
31+
32+
// searches the inclusive range [minValue, maxValue].
33+
// credits: https://matthiasott.com/notes/write-your-media-queries-in-pixels-not-ems
34+
export function mqBinarySearch(feature, minValue, maxValue, step, unit) {
35+
if (maxValue - minValue < step) {
36+
return minValue;
37+
}
38+
const mid = Math.ceil((minValue + maxValue) / 2 / step) * step;
39+
if (matchMedia(`screen and (min-${feature}:${mid}${unit})`).matches) {
40+
return mqBinarySearch(feature, mid, maxValue, step, unit); // feature is >= mid
41+
}
42+
return mqBinarySearch(feature, minValue, mid - step, step, unit); // feature is < mid
43+
}

web_src/less/_base.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1866,7 +1866,7 @@ table th[data-sortt-desc] {
18661866
vertical-align: -.075em;
18671867

18681868
@supports (-webkit-hyphens:none) {
1869-
& {
1869+
body:not(.safari-above125) & {
18701870
font-size: inherit;
18711871
vertical-align: inherit;
18721872
img {

0 commit comments

Comments
 (0)