Skip to content

Commit

Permalink
Merge pull request #44 from cobaltinc/park/drawer-events
Browse files Browse the repository at this point in the history
Drawer 의 Transition 이벤트시 외부함수를 주입할수 있도록 변경했다
  • Loading branch information
kciter authored Nov 13, 2023
2 parents 64e7677 + 29092c4 commit 0e58531
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions packages/co-design-core/src/components/Drawer/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ export interface DrawerProps extends CoComponentProps<DrawerStylesNames>, Omit<R

/** Drawer 컴포넌트가 닫힐 때 실행됩니다. */
onClose(): void;

/** Drawer 컴포넌트가 열리는 진입 트랜지션이 시작되면 실행됩니다. */
onEnter?(): void;

/** Drawer 컴포넌트가 열리는 진입 트랜지션이 끝나면 실행됩니다. */
onEntered?(): void;

/** Drawer 컴포넌트가 닫히는 종료 트랜지션이 시작되면 실행됩니다. */
onExit?(): void;

/** Drawer 컴포넌트가 닫히는 종료 트랜지션이 끝나면 실행됩니다. */
onExited?(): void;
}

const transitions: Record<DrawerPosition, CoTransition> = {
Expand Down Expand Up @@ -108,6 +120,10 @@ export const CoDrawer = ({
onClose,
className,
overrideStyles,
onEnter,
onEntered,
onExit,
onExited,
...props
}: DrawerProps) => {
const { classes, cx, theme } = useStyles({ size, position }, { overrideStyles, name: 'Drawer' });
Expand Down Expand Up @@ -135,8 +151,16 @@ export const CoDrawer = ({

return (
<GroupedTransition
onExited={() => lockScroll(false)}
onEntered={() => lockScroll(!noScrollLock && true)}
onExit={onExit}
onExited={() => {
lockScroll(false);
if (onExited) onExited();
}}
onEnter={onEnter}
onEntered={() => {
lockScroll(!noScrollLock && true);
if (onEntered) onEntered();
}}
mounted={opened}
transitions={{
overlay: { duration: transitionDuration / 2, transition: 'fade', timingFunction: 'ease' },
Expand Down

0 comments on commit 0e58531

Please sign in to comment.