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

Commit 9f37338

Browse files
authored
feat: DEV-4187: Select regions without 300ms lag (#1149)
* feat: DEV-4187: Select regions without 300ms lag * Improve unselection speed as well for most configs
1 parent 6e5130f commit 9f37338

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/mixins/KonvaRegion.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,29 @@ export const KonvaRegionMixin = types.model({})
3838

3939
if (e) e.cancelBubble = true;
4040

41+
const selectAction = () => {
42+
self._selectArea(additiveMode);
43+
deferredSelectId = null;
44+
};
45+
4146
if (annotation.editable && annotation.relationMode) {
4247
annotation.addRelation(self);
4348
annotation.stopRelationMode();
4449
annotation.regionStore.unselectAll();
4550
} else {
51+
// Skip double click emulation when there is nothing to focus
52+
if (!self.perRegionFocusTarget) {
53+
selectAction();
54+
return;
55+
}
56+
// Double click emulation
4657
if (deferredSelectId) {
4758
clearTimeout(deferredSelectId);
4859
self.requestPerRegionFocus();
4960
deferredSelectId = null;
5061
annotation.selectArea(self);
5162
} else {
52-
deferredSelectId = setTimeout(() => {
53-
self._selectArea(additiveMode);
54-
deferredSelectId = null;
55-
}, 300);
63+
deferredSelectId = setTimeout(selectAction, 300);
5664
}
5765
}
5866
},

0 commit comments

Comments
 (0)