import { _stopPropagation } from '@/utils/index'

/** 与 douyin-vue 一致：用 pointer 事件代替 click，避免滑动后点击延迟与 tap 高亮遮罩 */
export function useClick() {
  return {
    mounted(el: HTMLElement, binding: { value?: (e: Event) => void }) {
      el.addEventListener('pointerdown', (e) => _stopPropagation(e))
      el.addEventListener('pointerup', (e) => {
        _stopPropagation(e)
        binding.value?.(e)
      })
    },
    unmounted() {
      // directive cleanup handled by Vue when element is removed
    },
  }
}
