Skip to content

Commit

Permalink
fix: framer modal enter motion
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Jul 2, 2024
1 parent 3fa97c3 commit c5f0a59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/ui/modal/stacked/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Divider } from '~/components/ui/divider'
import { microReboundPreset } from '~/constants/spring'
import { useEventCallback } from '~/hooks/common/use-event-callback'
import { useIsUnMounted } from '~/hooks/common/use-is-unmounted'
import { stopPropagation } from '~/lib/dom'
import { nextFrame, stopPropagation } from '~/lib/dom'
import { clsxm } from '~/lib/helper'
import { jotaiStore } from '~/lib/store'

Expand Down Expand Up @@ -90,7 +90,9 @@ export const Modal: Component<{
const animateController = useAnimationControls()
useEffect(() => {
if (isMobile) return
animateController.start(enterStyle)
nextFrame(() => {
animateController.start(enterStyle)
})
}, [animateController, isMobile])
const noticeModal = useCallback(() => {
animateController
Expand Down
3 changes: 3 additions & 0 deletions src/lib/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ export const transitionViewIfSupported = (updateCb: () => any) => {
export function escapeSelector(selector: string) {
return selector.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, '\\$&')
}

export const nextFrame = (fn: () => void) =>
requestAnimationFrame(() => requestAnimationFrame(fn))

0 comments on commit c5f0a59

Please sign in to comment.