refactor: extract debounce logic into shared composable
- Create useDebounce composable to avoid code duplication - Apply debounce to TextSettings margin/padding inputs - Harmonize debounce delay to 500ms across all components - Fix input lag when typing values like "30mm" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
35c9ab1d3b
commit
681517db21
5 changed files with 40 additions and 29 deletions
15
src/composables/useDebounce.js
Normal file
15
src/composables/useDebounce.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* Composable for debounced updates
|
||||
* @param {number} delay - Debounce delay in milliseconds (default: 500ms)
|
||||
* @returns {Function} debouncedUpdate function
|
||||
*/
|
||||
export function useDebounce(delay = 500) {
|
||||
let timer = null;
|
||||
|
||||
const debouncedUpdate = (callback) => {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(callback, delay);
|
||||
};
|
||||
|
||||
return { debouncedUpdate };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue