index.js 775 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var shared = require('@vue/shared');
  4. const useSameTarget = (handleClick) => {
  5. if (!handleClick) {
  6. return { onClick: shared.NOOP, onMousedown: shared.NOOP, onMouseup: shared.NOOP };
  7. }
  8. let mousedownTarget = false;
  9. let mouseupTarget = false;
  10. const onClick = (e) => {
  11. if (mousedownTarget && mouseupTarget) {
  12. handleClick(e);
  13. }
  14. mousedownTarget = mouseupTarget = false;
  15. };
  16. const onMousedown = (e) => {
  17. mousedownTarget = e.target === e.currentTarget;
  18. };
  19. const onMouseup = (e) => {
  20. mouseupTarget = e.target === e.currentTarget;
  21. };
  22. return { onClick, onMousedown, onMouseup };
  23. };
  24. exports.useSameTarget = useSameTarget;
  25. //# sourceMappingURL=index.js.map