Skip to content

adds mouseenter and mouseleave #556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/ReactCrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export interface ReactCropProps {
onDragStart?: (e: PointerEvent) => void
/** A callback which happens when a user releases the cursor or touch after dragging or resizing. */
onDragEnd?: (e: PointerEvent) => void
/** A callback which happens when a user enters their cursor over the crop box */
onMouseEnter?: () => void
/** A callback which happens when a user exits their cursor from the crop box */
onMouseLeave?: () => void
/** Render a custom element in crop selection. */
renderSelectionAddon?: (state: ReactCropState) => React.ReactNode
/** Show rule of thirds lines in the cropped area. Defaults to false. */
Expand Down Expand Up @@ -679,6 +683,8 @@ export class ReactCrop extends PureComponent<ReactCropProps, ReactCropState> {
renderSelectionAddon,
ruleOfThirds,
crop,
onMouseEnter,
onMouseLeave
} = this.props
const style = this.getCropStyle()

Expand All @@ -694,6 +700,8 @@ export class ReactCrop extends PureComponent<ReactCropProps, ReactCropState> {
aria-label={ariaLabels.cropArea}
tabIndex={0}
onKeyDown={this.onComponentKeyDown}
onMouseEnter={() => onMouseEnter ? onMouseEnter() : null}
onMouseLeave={() => onMouseLeave ? onMouseLeave() : null}
role="group"
>
{!disabled && !locked && (
Expand Down