index.mjs 662 B

12345678910111213141516171819202122232425
  1. import { NOOP } from '@vue/shared';
  2. const useSameTarget = (handleClick) => {
  3. if (!handleClick) {
  4. return { onClick: NOOP, onMousedown: NOOP, onMouseup: NOOP };
  5. }
  6. let mousedownTarget = false;
  7. let mouseupTarget = false;
  8. const onClick = (e) => {
  9. if (mousedownTarget && mouseupTarget) {
  10. handleClick(e);
  11. }
  12. mousedownTarget = mouseupTarget = false;
  13. };
  14. const onMousedown = (e) => {
  15. mousedownTarget = e.target === e.currentTarget;
  16. };
  17. const onMouseup = (e) => {
  18. mouseupTarget = e.target === e.currentTarget;
  19. };
  20. return { onClick, onMousedown, onMouseup };
  21. };
  22. export { useSameTarget };
  23. //# sourceMappingURL=index.mjs.map