Skip to content

Commit eecc003

Browse files
committed
Feat: added a new event handler named on image hover
1 parent e789e5f commit eecc003

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
Changelog
22

3+
# v3.1.0 [2024-12-05]
4+
5+
## Minor Release
6+
7+
### Features
8+
- Adds a new event handler named `onImageHover` which is applicable in User mode
9+
---
10+
311
# v3.0.1 [2024-12-05]
412

513
## Patch Release

src/components/workspace/elements/image.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@ export interface IImageProps extends IImage {
1010
}
1111

1212
const Image: React.FC<IImageProps> = forwardRef(
13-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
14-
({ x, y, id, href, width, height, rotation, consumer, isSelected, element: _, ...props }, ref: any) => {
13+
14+
({ x, y, id, href, width, height, rotation, consumer, isSelected, element, ...props }, ref: any) => {
15+
const onMouseOver = (e: React.MouseEvent<SVGElement>) => {
16+
if (consumer.mode === "user") {
17+
consumer.events?.onImageHover?.(element, {
18+
x: e.clientX,
19+
y: e.clientY
20+
});
21+
}
22+
};
1523
return (
1624
<image
1725
ref={ref}
@@ -34,6 +42,7 @@ const Image: React.FC<IImageProps> = forwardRef(
3442
transformOrigin: `center`,
3543
...consumer.styles?.elements?.image?.base?.properties
3644
}}
45+
onMouseOver={onMouseOver}
3746
/>
3847
);
3948
}

src/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export interface IEvents {
3636
onSeatSelectionChange?: (seats: IPopulatedSeat[]) => void;
3737
/** Only applicable in user mode. Fired when the user tries to select more seats than the maxSeatSelectionCount */
3838
onMaxSeatSelectionCountReached?: () => void;
39+
/** Only applicable in user mode */
40+
onImageHover?: (seat: IImage, coords: ICoordinates) => void;
3941
onWorkspaceHover?: () => void;
4042
onWorkspaceLoad?: () => void;
4143
onSectionClick?: (section: ISection) => void;

0 commit comments

Comments
 (0)