Skip to content

Commit

Permalink
feat: threshold 를 외부에서 결정해줄수있게 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
skiende74 committed Nov 14, 2024
1 parent 10e937c commit 5196255
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions frontend/src/components/_common/Tabs/TabContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ export const TabProvider = ({ children, defaultTab = 0 }: Props) => {
const [currentTabId, setCurrentTabId] = useState<number>(defaultTab);

// 드래그로 탭이동을 위한 훅을 리턴에 제공
const useDragForTab = () => {
const useDragForTab = (dragThreshold: number = DRAG_THRESHOLD_PIXEL) => {
const ref = useRef<HTMLElement>(null);
useMouseDrag(ref, (S, E) => {
const TAB_COUNT = DefaultChecklistTabsNames.length;

setCurrentTabId(tabId => {
const isLeftDrag = E.x - S.x > DRAG_THRESHOLD_PIXEL;
const isRightDrag = S.x - E.x > DRAG_THRESHOLD_PIXEL;
const isLeftDrag = E.x - S.x > dragThreshold;
const isRightDrag = S.x - E.x > dragThreshold;
if (isLeftDrag) return remainOp(tabId - 1, TAB_COUNT);
if (isRightDrag) return remainOp(tabId + 1, TAB_COUNT);
return tabId;
Expand Down

0 comments on commit 5196255

Please sign in to comment.