Skip to content

Commit

Permalink
Make subtargets as rect
Browse files Browse the repository at this point in the history
  • Loading branch information
dukobpa3 committed Apr 9, 2024
1 parent 98a1d84 commit 05869ea
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/events/src/apply-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const applyEventAction = <T extends Taggable>(data: T, action: EventAction): boo
}

const isSubIdsValid = (event: Event) => {
if(!event.tagretSubIds) return true;
if(event.tagretSubIds.length == event.targetIds.length) return true;
if(!event.subtargetCoords) return true;
if(event.subtargetCoords.length == event.targetIds.length) return true;
return false;
}

Expand Down
24 changes: 23 additions & 1 deletion packages/events/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,22 @@ export interface Event {
id: string;
date?: string;
targetIds: string[];
tagretSubIds?: string[];
// means that can't be more than one same object in one file.
// made for faces, so seems useful
// for example we have file 02f3p with faces 0, 1, 2
// in one event we can put only one faceTag. So in case we will make bulk renaming we will get three events:
// targetIds[02f3p], tagretSubIds[0]
// targetIds[02f3p], tagretSubIds[1]
// targetIds[02f3p], tagretSubIds[2]
//
// espesially important for multiedit of many files, for example files 02f3p, jhr65, 3lh7a
// they have same person, but it have different places in each file, then we will get ONE event:
// targetIds[02f3p, jhr65, 3lh7a], tagretSubIds[5, 0, 3]
//
// this approach is kind of trade off and we loose some benefits in single file/many faces edit
// but makes multifiles edit better

subtargetCoords?: Rect[];
actions: EventAction[];
}

Expand All @@ -12,4 +27,11 @@ export interface EventAction {
value: string;
}

export interface Rect {
x: number;
y: number;
width: number;
height: number;
}

export type EventListener = (event: Event) => void;

0 comments on commit 05869ea

Please sign in to comment.