Skip to content

Commit

Permalink
Feat: added a new event handler named on image hover
Browse files Browse the repository at this point in the history
  • Loading branch information
Akalanka47000 committed Dec 5, 2024
1 parent e789e5f commit eecc003
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
Changelog

# v3.1.0 [2024-12-05]

## Minor Release

### Features
- Adds a new event handler named `onImageHover` which is applicable in User mode
---

# v3.0.1 [2024-12-05]

## Patch Release
Expand Down
13 changes: 11 additions & 2 deletions src/components/workspace/elements/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ export interface IImageProps extends IImage {
}

const Image: React.FC<IImageProps> = forwardRef(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
({ x, y, id, href, width, height, rotation, consumer, isSelected, element: _, ...props }, ref: any) => {

({ x, y, id, href, width, height, rotation, consumer, isSelected, element, ...props }, ref: any) => {
const onMouseOver = (e: React.MouseEvent<SVGElement>) => {
if (consumer.mode === "user") {
consumer.events?.onImageHover?.(element, {
x: e.clientX,
y: e.clientY
});
}
};
return (
<image
ref={ref}
Expand All @@ -34,6 +42,7 @@ const Image: React.FC<IImageProps> = forwardRef(
transformOrigin: `center`,
...consumer.styles?.elements?.image?.base?.properties
}}
onMouseOver={onMouseOver}
/>
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export interface IEvents {
onSeatSelectionChange?: (seats: IPopulatedSeat[]) => void;
/** Only applicable in user mode. Fired when the user tries to select more seats than the maxSeatSelectionCount */
onMaxSeatSelectionCountReached?: () => void;
/** Only applicable in user mode */
onImageHover?: (seat: IImage, coords: ICoordinates) => void;
onWorkspaceHover?: () => void;
onWorkspaceLoad?: () => void;
onSectionClick?: (section: ISection) => void;
Expand Down

0 comments on commit eecc003

Please sign in to comment.