Skip to content

Commit

Permalink
refactor: use scroll lock 훅 추가 (#ATR-597)
Browse files Browse the repository at this point in the history
  • Loading branch information
LC-02s committed Aug 24, 2024
1 parent a212f36 commit 925ea74
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/design-system/packages/hooks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './use-scroll-observer'
export * from './use-scroll-progress'
export * from './use-document-event'
export * from './use-timeout'
export * from './use-scroll-lock'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as useScrollLock } from './useScrollLock'
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'

export default function useScrollLock(status: boolean) {
React.useEffect(() => {
if (status) {
document.body.style.touchAction = 'none'
document.body.style.overflow = 'hidden'
} else {
document.body.style.touchAction = ''
document.body.style.overflow = ''
}
return () => {
document.body.style.touchAction = ''
document.body.style.overflow = ''
}
}, [status])
}

0 comments on commit 925ea74

Please sign in to comment.