Created
June 8, 2022 03:20
-
-
Save PrasathRavichandran/5f6f984c49b52f00c323797a9e337c44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {useRef} from 'react'; | |
... | |
const inputRef = useRef<any>(null); | |
... | |
const onFocus = ()=>{ | |
InputLength.value = {width: '90%'}; | |
SearchTextPlacement.value = {transformX: 0}; | |
CancelBtn.value = {transformX: 0}; | |
} | |
const onCancelAnimation = () => { | |
InputLength.value = {width: '100%'}; | |
SearchTextPlacement.value = { | |
transformX: (Dimensions.get('window').width - 140) / 2, | |
}; | |
CancelBtn.value = {transformX: 100}; | |
inputRef.current.blur(); | |
}; | |
... | |
<TextInput | |
placeholder={'Search'} | |
style={{fontSize: 16, paddingRight: 20}} | |
onFocus={onFocus} | |
ref={inputRef} | |
/> | |
... | |
<Animated.View style={[styles.cancelBtnContainer, CancelBtnStyles]}> | |
<TouchableOpacity onPress={onCancelAnimation}> | |
<Text>Cancel</Text> | |
</TouchableOpacity> | |
</Animated.View> | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment