Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit 3e71527

Browse files
authored
fix: DEV-1285: Fix crosshair works with zooming and rotating of image (#433)
1 parent bd3fa2b commit 3e71527

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/components/ImageView/ImageView.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { ImageViewProvider } from "./ImageViewContext";
1919
import { Hotkey } from "../../core/Hotkey";
2020
import { useObserver } from "mobx-react-lite";
2121
import ResizeObserver from "../../utils/resize-observer";
22+
import { FF_DEV_1285, isFF } from "../../utils/feature-flags";
2223

2324
Konva.showWarnings = false;
2425

@@ -266,6 +267,11 @@ const Crosshair = memo(forwardRef(({ width, height }, ref) => {
266267
const [visible, setVisible] = useState(false);
267268
const strokeWidth = 1;
268269
const dashStyle = [3,3];
270+
let enableStrokeScale = true;
271+
272+
if (isFF(FF_DEV_1285)) {
273+
enableStrokeScale = false;
274+
}
269275

270276
if (ref) {
271277
ref.current = {
@@ -298,13 +304,15 @@ const Crosshair = memo(forwardRef(({ width, height }, ref) => {
298304
points={pointsH}
299305
stroke="#fff"
300306
strokeWidth={strokeWidth}
307+
strokeScaleEnabled={enableStrokeScale}
301308
/>
302309
<Line
303310
name="v-black"
304311
points={pointsH}
305312
stroke="#000"
306313
strokeWidth={strokeWidth}
307314
dash={dashStyle}
315+
strokeScaleEnabled={enableStrokeScale}
308316
/>
309317
</Group>
310318
<Group>
@@ -313,13 +321,15 @@ const Crosshair = memo(forwardRef(({ width, height }, ref) => {
313321
points={pointsV}
314322
stroke="#fff"
315323
strokeWidth={strokeWidth}
324+
strokeScaleEnabled={enableStrokeScale}
316325
/>
317326
<Line
318327
name="h-black"
319328
points={pointsV}
320329
stroke="#000"
321330
strokeWidth={strokeWidth}
322331
dash={dashStyle}
332+
strokeScaleEnabled={enableStrokeScale}
323333
/>
324334
</Group>
325335
</Layer>
@@ -449,7 +459,11 @@ export default observer(
449459
if (this.crosshairRef.current) {
450460
const { x, y } = e.currentTarget.getPointerPosition();
451461

452-
this.crosshairRef.current.updatePointer(x, y);
462+
if (isFF(FF_DEV_1285)) {
463+
this.crosshairRef.current.updatePointer(...this.props.item.fixZoomedCoords([x, y]));
464+
} else {
465+
this.crosshairRef.current.updatePointer(x, y);
466+
}
453467
}
454468
}
455469

@@ -816,8 +830,8 @@ export default observer(
816830
{item.crosshair && (
817831
<Crosshair
818832
ref={this.crosshairRef}
819-
width={item.stageComponentSize.width}
820-
height={item.stageComponentSize.height}
833+
width={isFF(FF_DEV_1285) ? item.stageWidth : item.stageComponentSize.width}
834+
height={isFF(FF_DEV_1285) ? item.stageHeight : item.stageComponentSize.height}
821835
/>
822836
)}
823837
</Stage>

src/utils/feature-flags.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const FEATURE_FLAGS = window.APP_SETTINGS?.feature_flags || {};
2+
3+
// Fix crosshair working with zoom & rotation
4+
export const FF_DEV_1285 = "ff_front_dev_1285_crosshair_wrong_zoom_140122_short";
5+
6+
export function isFF(id) {
7+
return FEATURE_FLAGS[id] === true;
8+
}

0 commit comments

Comments
 (0)