Skip to content
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

adds mouseenter and mouseleave #556

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jaredshaunsmith
Copy link

We found a usecase at VSCO to need to know when a mouseEnter and mouseLeave event fires in over the crop selection box. This PR addresses that by adding them to the spec.

Would love to see this get merged and will actively respond and update if there's any feedback.

Thanks!

@sekoyo
Copy link
Owner

sekoyo commented Sep 1, 2023

Rather than add these props (and the list of possible attributes it can take are lengthy), how about using renderSelectionAddon={(state: CropState) => <CropAddon />}?

import { useState } from 'react'

/*
.crop-addon {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}
*/
import './CropAddon.css'

export function CropAddon() {
  const [overState, setOverState] = useState(false)

  return (
    <div
      className="crop-addon"
      onPointerEnter={() => setOverState(true)}
      onPointerLeave={() => setOverState(false)}
    >
      <h1>{overState ? 'Pointer Over' : 'Pointer Left'}</h1>
    </div>
  )
}

Demo: https://codesandbox.io/s/react-image-crop-demo-with-react-hooks-renderselectionaddon-xtqs6k

@jaredshaunsmith
Copy link
Author

Seems a bit like a hammer for a screwdriver's job imho. Given that react / html handles mouse events like this natively we'd rather not implement this this way.

Totally hear your concern on bloating the props list with adding too many but I feel these are table stakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants