You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
2.7 KiB
1 line
2.7 KiB
1 month ago
|
{"version":3,"file":"index.js","sources":["../../../../../packages/directives/repeat-click/index.ts"],"sourcesContent":["import { isFunction } from '@element-plus/utils'\n\nimport type { ObjectDirective } from 'vue'\n\nexport const REPEAT_INTERVAL = 100\nexport const REPEAT_DELAY = 600\n\nexport interface RepeatClickOptions {\n interval?: number\n delay?: number\n handler: (...args: unknown[]) => unknown\n}\n\nexport const vRepeatClick: ObjectDirective<\n HTMLElement,\n RepeatClickOptions | RepeatClickOptions['handler']\n> = {\n beforeMount(el, binding) {\n const value = binding.value\n const { interval = REPEAT_INTERVAL, delay = REPEAT_DELAY } = isFunction(\n value\n )\n ? {}\n : value\n\n let intervalId: ReturnType<typeof setInterval> | undefined\n let delayId: ReturnType<typeof setTimeout> | undefined\n\n const handler = () => (isFunction(value) ? value() : value.handler())\n\n const clear = () => {\n if (delayId) {\n clearTimeout(delayId)\n delayId = undefined\n }\n if (intervalId) {\n clearInterval(intervalId)\n intervalId = undefined\n }\n }\n\n el.addEventListener('mousedown', (evt: MouseEvent) => {\n if (evt.button !== 0) return\n clear()\n handler()\n\n document.addEventListener('mouseup', () => clear(), {\n once: true,\n })\n\n delayId = setTimeout(() => {\n intervalId = setInterval(() => {\n handler()\n }, interval)\n }, delay)\n })\n },\n}\n"],"names":["isFunction"],"mappings":";;;;;;;AACY,MAAC,eAAe,GAAG,IAAI;AACvB,MAAC,YAAY,GAAG,IAAI;AACpB,MAAC,YAAY,GAAG;AAC5B,EAAE,WAAW,CAAC,EAAE,EAAE,OAAO,EAAE;AAC3B,IAAI,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AAChC,IAAI,MAAM,EAAE,QAAQ,GAAG,eAAe,EAAE,KAAK,GAAG,YAAY,EAAE,GAAGA,iBAAU,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;AAChG,IAAI,IAA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