-
Notifications
You must be signed in to change notification settings - Fork 734
Fix/dialog animation #891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/dialog animation #891
Changes from 8 commits
67bd102
3859cff
fab6496
ffccad3
0be0184
2c78a24
32476ed
a86c537
5857e23
9607908
9a6f7db
7d04519
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/// <reference types="react" /> | ||
interface Props { | ||
dialogVisibility: boolean; | ||
modalVisibility: boolean; | ||
overlayBackgroundColor: string; | ||
} | ||
declare const _default: ({ dialogVisibility, modalVisibility, overlayBackgroundColor }: Props) => JSX.Element; | ||
export default _default; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React, {useRef, useEffect, useCallback, useMemo} from 'react'; | ||
import View from '../view'; | ||
import {Animated} from 'react-native'; | ||
|
||
interface Props { | ||
dialogVisibility: boolean; | ||
modalVisibility: boolean; | ||
overlayBackgroundColor: string; | ||
} | ||
|
||
export default ({ | ||
dialogVisibility, | ||
modalVisibility, | ||
overlayBackgroundColor | ||
}: Props) => { | ||
const fadeAnimation = useRef(new Animated.Value(0)).current; | ||
|
||
useEffect(() => { | ||
if (!dialogVisibility) { | ||
animateFading(0); | ||
} | ||
}, [dialogVisibility]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The hooks plugin says you are missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed the warnings.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know, and it has bugs sometimes (see AutoLockScrollView, it cannot recognize that not all the |
||
|
||
useEffect(() => { | ||
if (modalVisibility) { | ||
animateFading(1); | ||
} | ||
}, [modalVisibility]); | ||
M-i-k-e-l marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const animateFading = useCallback((toValue) => { | ||
Animated.timing(fadeAnimation, { | ||
toValue, | ||
duration: 400, | ||
useNativeDriver: true | ||
}).start(); | ||
}, []); | ||
M-i-k-e-l marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const style = useMemo(() => { | ||
return { | ||
opacity: fadeAnimation, | ||
backgroundColor: overlayBackgroundColor | ||
}; | ||
}, [overlayBackgroundColor]); | ||
M-i-k-e-l marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return <View absF animated style={style} pointerEvents="none"/>; | ||
}; |
Uh oh!
There was an error while loading. Please reload this page.