@searpent/react-image-annotate 2.0.46 → 2.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Annotator/index.js
CHANGED
|
@@ -76,6 +76,7 @@ export var Annotator = function Annotator(_ref) {
|
|
|
76
76
|
groupColors = _ref.groupColors,
|
|
77
77
|
onRecalc = _ref.onRecalc,
|
|
78
78
|
onSave = _ref.onSave,
|
|
79
|
+
onSelectedImageChange = _ref.onSelectedImageChange,
|
|
79
80
|
albumMetadata = _ref.albumMetadata,
|
|
80
81
|
metadataConfigs = _ref.metadataConfigs,
|
|
81
82
|
_ref$lockedImages = _ref.lockedImages,
|
|
@@ -254,9 +255,25 @@ export var Annotator = function Annotator(_ref) {
|
|
|
254
255
|
type: "ADD_GROUP",
|
|
255
256
|
group: group
|
|
256
257
|
});
|
|
257
|
-
}; // trigger
|
|
258
|
+
}; // trigger onSelectedImageChange() hook when image changed
|
|
258
259
|
|
|
259
260
|
|
|
261
|
+
useEffect(function () {
|
|
262
|
+
var _state$lastAction;
|
|
263
|
+
|
|
264
|
+
var createdAt = new Date();
|
|
265
|
+
|
|
266
|
+
if (typeof onSelectedImageChange === 'function' && ((_state$lastAction = state.lastAction) === null || _state$lastAction === void 0 ? void 0 : _state$lastAction.type) === 'SELECT_IMAGE' && (state === null || state === void 0 ? void 0 : state.selectedImage) !== state.previouslySelectedImage) {
|
|
267
|
+
onSelectedImageChange({
|
|
268
|
+
selectedImage: state === null || state === void 0 ? void 0 : state.selectedImage,
|
|
269
|
+
previouslySelectedImage: state.previouslySelectedImage,
|
|
270
|
+
images: state.images,
|
|
271
|
+
albumMetadata: state.albumMetadata,
|
|
272
|
+
createdAt: createdAt
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}, [state.previouslySelectedImage, state.selectedImage, onSelectedImageChange, state.images, state.albumMetadata, state]); // trigger this on every BBox manipulation (there is currently no way to detect adding of new box!)
|
|
276
|
+
|
|
260
277
|
useEffect(function () {
|
|
261
278
|
if (!state.lastAction || !["BEGIN_BOX_TRANSFORM", "CHANGE_REGION", "DELETE_REGION", "DELETE_SELECTED_REGION", "UPDATE_METADATA", "SELECT_CLASSIFICATION"].includes(state.lastAction.type)) {
|
|
262
279
|
return;
|
|
@@ -114,6 +114,7 @@ export default (function (state, action) {
|
|
|
114
114
|
src = _ref.src,
|
|
115
115
|
frameTime = _ref.frameTime;
|
|
116
116
|
|
|
117
|
+
state = setIn(state, ["previouslySelectedImage"], state.selectedImage);
|
|
117
118
|
return setIn(setIn(state, ["selectedImage"], index), ["selectedImageFrameTime"], frameTime);
|
|
118
119
|
};
|
|
119
120
|
|