diff --git a/src/components/video/VideoLeft.vue b/src/components/video/VideoLeft.vue index 35fb514..4b6a90c 100644 --- a/src/components/video/VideoLeft.vue +++ b/src/components/video/VideoLeft.vue @@ -217,6 +217,7 @@ onUnmounted(() => { flex: 1; min-height: 0; overflow-y: auto; + padding-bottom: 96px; } .create-button-container { z-index: 999; @@ -225,6 +226,7 @@ onUnmounted(() => { left: 0; width: 100%; padding: 16px; + pointer-events: none; // background: linear-gradient(180deg, rgba(2, 11, 19, 0) 0%, #0f0f19 100%); // position: relative; } @@ -243,6 +245,7 @@ onUnmounted(() => { font-weight: 600 !important; cursor: pointer; transition: all 0.2s; + pointer-events: auto; } .create-button .price-info { font-size: 16px; diff --git a/src/utlis/debounce.ts b/src/utlis/debounce.ts new file mode 100644 index 0000000..1d64d00 --- /dev/null +++ b/src/utlis/debounce.ts @@ -0,0 +1,42 @@ +export type DebouncedFunction any> = (( + ...args: Parameters +) => void) & { + cancel: () => void; +}; + +export const debounce = any>( + fn: T, + wait = 300, + immediate = true +): DebouncedFunction => { + let timer: ReturnType | null = null; + + const debounced = ((...args: Parameters) => { + const shouldCallNow = immediate && timer === null; + + if (timer) { + clearTimeout(timer); + } + + timer = setTimeout(() => { + timer = null; + + if (!immediate) { + void fn(...args); + } + }, wait); + + if (shouldCallNow) { + void fn(...args); + } + }) as DebouncedFunction; + + debounced.cancel = () => { + if (!timer) return; + + clearTimeout(timer); + timer = null; + }; + + return debounced; +};