Fix intelligent scissors blocking (#3825)

* added event repeat check

* fix eslint errors
main
Kirill Lakhov 4 years ago committed by GitHub
parent fb6305fff8
commit 3f8b9e4823
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,19 +22,33 @@ export interface InteractionHandler {
export class InteractionHandlerImpl implements InteractionHandler { export class InteractionHandlerImpl implements InteractionHandler {
private onInteraction: (shapes: InteractionResult[] | null, shapesUpdated?: boolean, isDone?: boolean) => void; private onInteraction: (shapes: InteractionResult[] | null, shapesUpdated?: boolean, isDone?: boolean) => void;
private configuration: Configuration; private configuration: Configuration;
private geometry: Geometry; private geometry: Geometry;
private canvas: SVG.Container; private canvas: SVG.Container;
private interactionData: InteractionData; private interactionData: InteractionData;
private cursorPosition: { x: number; y: number }; private cursorPosition: { x: number; y: number };
private shapesWereUpdated: boolean; private shapesWereUpdated: boolean;
private interactionShapes: SVG.Shape[]; private interactionShapes: SVG.Shape[];
private currentInteractionShape: SVG.Shape | null; private currentInteractionShape: SVG.Shape | null;
private crosshair: Crosshair; private crosshair: Crosshair;
private threshold: SVG.Rect | null; private threshold: SVG.Rect | null;
private thresholdRectSize: number; private thresholdRectSize: number;
private intermediateShape: PropType<InteractionData, 'intermediateShape'>; private intermediateShape: PropType<InteractionData, 'intermediateShape'>;
private drawnIntermediateShape: SVG.Shape; private drawnIntermediateShape: SVG.Shape;
private thresholdWasModified: boolean; private thresholdWasModified: boolean;
private prepareResult(): InteractionResult[] { private prepareResult(): InteractionResult[] {
@ -310,6 +324,7 @@ export class InteractionHandlerImpl implements InteractionHandler {
} }
private selectize(value: boolean, shape: SVG.Element, erroredShape = false): void { private selectize(value: boolean, shape: SVG.Element, erroredShape = false): void {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this; const self = this;
if (value) { if (value) {
@ -450,7 +465,7 @@ export class InteractionHandlerImpl implements InteractionHandler {
}); });
window.addEventListener('keydown', (e: KeyboardEvent): void => { window.addEventListener('keydown', (e: KeyboardEvent): void => {
if (this.interactionData.enabled && e.keyCode === 17) { if (!e.repeat && this.interactionData.enabled && e.keyCode === 17) {
if (this.interactionData.onChangeToolsBlockerState && !this.thresholdWasModified) { if (this.interactionData.onChangeToolsBlockerState && !this.thresholdWasModified) {
this.interactionData.onChangeToolsBlockerState('keydown'); this.interactionData.onChangeToolsBlockerState('keydown');
} }

Loading…
Cancel
Save