智慧水务管理系统 - 精河县供水工程综合管理平台

index.mjs 715B

123456789101112131415161718192021222324252627282930
  1. import { NOOP } from "../../utils/functions.mjs";
  2. //#region ../../packages/hooks/use-same-target/index.ts
  3. const useSameTarget = (handleClick) => {
  4. if (!handleClick) return {
  5. onClick: NOOP,
  6. onMousedown: NOOP,
  7. onMouseup: NOOP
  8. };
  9. let mousedownTarget = false;
  10. let mouseupTarget = false;
  11. const onClick = (e) => {
  12. if (mousedownTarget && mouseupTarget) handleClick(e);
  13. mousedownTarget = mouseupTarget = false;
  14. };
  15. const onMousedown = (e) => {
  16. mousedownTarget = e.target === e.currentTarget;
  17. };
  18. const onMouseup = (e) => {
  19. mouseupTarget = e.target === e.currentTarget;
  20. };
  21. return {
  22. onClick,
  23. onMousedown,
  24. onMouseup
  25. };
  26. };
  27. //#endregion
  28. export { useSameTarget };
  29. //# sourceMappingURL=index.mjs.map