chore: upgrade dependencies
This commit is contained in:
1 parent
c3f234076b
commit
955366b511
20 files changed
+957
-1100
No files matched your search
@@ -5,9 +5,9 @@ import { useBarcodeScanner } from '../useBarcodeScanner';
|
||||
const decodeFromVideoDevice = vi.fn();
|
||||
|
||||
vi.mock('@zxing/browser', () => ({
|
||||
BrowserMultiFormatReader: vi.fn().mockImplementation(() => ({
|
||||
decodeFromVideoDevice,
|
||||
})),
|
||||
BrowserMultiFormatReader: vi.fn(function MockBrowserMultiFormatReader() {
|
||||
return { decodeFromVideoDevice };
|
||||
}),
|
||||
}));
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -7,7 +7,7 @@ interface LongPressOptions {
|
||||
}
|
||||
|
||||
export const useLongPress = ({ delay = 500, onLongPress, onClick }: LongPressOptions) => {
|
||||
const timerRef = useRef<number>();
|
||||
const timerRef = useRef<number | undefined>(undefined);
|
||||
const handledRef = useRef(false);
|
||||
|
||||
const start = useCallback(() => {
|
||||
|
||||
+17
-14
@@ -1,4 +1,4 @@
|
||||
import { useMemo, useRef } from 'react';
|
||||
import { useCallback, useMemo, useRef } from 'react';
|
||||
|
||||
interface SwipeConfig {
|
||||
onSwipeLeft?: () => void;
|
||||
@@ -9,26 +9,29 @@ interface SwipeConfig {
|
||||
export const useSwipe = ({ onSwipeLeft, onSwipeRight, threshold = 50 }: SwipeConfig) => {
|
||||
const startX = useRef<number | null>(null);
|
||||
|
||||
const onTouchStart = (e: React.TouchEvent) => {
|
||||
const onTouchStart = useCallback((e: React.TouchEvent) => {
|
||||
startX.current = e.changedTouches[0].screenX;
|
||||
};
|
||||
}, []);
|
||||
|
||||
const onTouchEnd = (e: React.TouchEvent) => {
|
||||
if (startX.current === null) return;
|
||||
const deltaX = e.changedTouches[0].screenX - startX.current;
|
||||
if (deltaX < -threshold) {
|
||||
onSwipeLeft?.();
|
||||
} else if (deltaX > threshold) {
|
||||
onSwipeRight?.();
|
||||
}
|
||||
startX.current = null;
|
||||
};
|
||||
const onTouchEnd = useCallback(
|
||||
(e: React.TouchEvent) => {
|
||||
if (startX.current === null) return;
|
||||
const deltaX = e.changedTouches[0].screenX - startX.current;
|
||||
if (deltaX < -threshold) {
|
||||
onSwipeLeft?.();
|
||||
} else if (deltaX > threshold) {
|
||||
onSwipeRight?.();
|
||||
}
|
||||
startX.current = null;
|
||||
},
|
||||
[onSwipeLeft, onSwipeRight, threshold],
|
||||
);
|
||||
|
||||
return useMemo(
|
||||
() => ({
|
||||
onTouchStart,
|
||||
onTouchEnd,
|
||||
}),
|
||||
[],
|
||||
[onTouchEnd, onTouchStart],
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user