|
1 | 1 | import { ShapeConfig } from 'konva/lib/Shape';
|
| 2 | +import { EllipseConfig } from 'konva/lib/shapes/Ellipse'; |
2 | 3 | import * as React from 'react';
|
3 | 4 | import { Ellipse, Group, Image, Rect } from 'react-konva';
|
4 | 5 | import { getDragOffset, registerDropHandler } from '../DropHandler';
|
@@ -105,6 +106,18 @@ const EllipseOutline: React.FC<OutlineProps> = ({
|
105 | 106 | showHighlight,
|
106 | 107 | strokeProps,
|
107 | 108 | }) => {
|
| 109 | + // Making the object always slightly elliptical works around a bug on |
| 110 | + // Firefox where it draws a very thick arc instead of dashes. |
| 111 | + // https://github.com/konvajs/konva/issues/1864 |
| 112 | + const firefoxHack = 1.0000001; |
| 113 | + |
| 114 | + if (width === height) { |
| 115 | + width *= firefoxHack; |
| 116 | + } |
| 117 | + if (highlightWidth === highlightHeight) { |
| 118 | + highlightWidth *= firefoxHack; |
| 119 | + } |
| 120 | + |
108 | 121 | return (
|
109 | 122 | <>
|
110 | 123 | {showHighlight && (
|
@@ -161,19 +174,23 @@ const MarkerRenderer: React.FC<RendererProps<MarkerObject>> = ({ object }) => {
|
161 | 174 | const iconX = (object.width - iconWidth) / 2;
|
162 | 175 | const iconY = (object.height - iconHeight) / 2;
|
163 | 176 |
|
| 177 | + const strokeWidth = 1; |
| 178 | + |
164 | 179 | const dashSize = getDashSize(object);
|
165 |
| - const strokeProps = { |
| 180 | + const strokeProps: Partial<EllipseConfig> = { |
166 | 181 | stroke: object.color,
|
167 |
| - strokeWidth: 1, |
| 182 | + strokeWidth, |
168 | 183 | shadowColor: object.color,
|
169 |
| - shadowBlur: 2, |
| 184 | + shadowBlur: 1, |
170 | 185 | dash: [dashSize, dashSize],
|
171 | 186 | };
|
172 | 187 |
|
173 |
| - const highlightOffset = strokeProps.strokeWidth * 4; |
| 188 | + const highlightOffset = strokeWidth * 4; |
174 | 189 | const highlightWidth = object.width + highlightOffset;
|
175 | 190 | const highlightHeight = object.height + highlightOffset;
|
176 | 191 |
|
| 192 | + console.log(strokeProps); |
| 193 | + |
177 | 194 | return (
|
178 | 195 | <ResizeableObjectContainer object={object} transformerProps={{ centeredScaling: true }}>
|
179 | 196 | {(groupProps) => (
|
|
0 commit comments