Skip to content

Commit 9fd3486

Browse files
committed
Make Firefox dash render hack stronger
Make dashed circle outlines even more elliptical on Firefox to see if this fully works around #35. Also adjusted the hack to only apply on Firefox (and derivatives) by checking for "Gecko" in the user agent.
1 parent 88578e1 commit 9fd3486

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/prefabs/Markers.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ShapeConfig } from 'konva/lib/Shape';
22
import { EllipseConfig } from 'konva/lib/shapes/Ellipse';
33
import * as React from 'react';
4+
import { useMemo } from 'react';
45
import { Ellipse, Group, Image, Rect } from 'react-konva';
56
import { getDragOffset, registerDropHandler } from '../DropHandler';
67
import { ALIGN_TO_PIXEL } from '../coord';
@@ -109,13 +110,17 @@ const EllipseOutline: React.FC<OutlineProps> = ({
109110
// Making the object always slightly elliptical works around a bug on
110111
// Firefox where it draws a very thick arc instead of dashes.
111112
// https://github.com/konvajs/konva/issues/1864
112-
const firefoxHack = 1.0000001;
113+
const isGecko = useMemo(() => navigator.userAgent.includes('Gecko'), []);
113114

114-
if (width === height) {
115-
width *= firefoxHack;
116-
}
117-
if (highlightWidth === highlightHeight) {
118-
highlightWidth *= firefoxHack;
115+
if (isGecko) {
116+
const geckoHack = 1.001;
117+
118+
if (width === height) {
119+
width *= geckoHack;
120+
}
121+
if (highlightWidth === highlightHeight) {
122+
highlightWidth *= geckoHack;
123+
}
119124
}
120125

121126
return (

0 commit comments

Comments
 (0)