@Evleneceksen
Yüksekliğin klavyenin göründüğü hızda hareket etmesini istemiyorsanız, en azından yüksekliğin yerine sıçramaması için LayoutAnimation'ı kullanabilirsiniz. Örneğin
LayoutAnimation'ı react-native'den içe aktarın ve bileşeninize aşağıdaki yöntemleri ekleyin.
getInitialState: function() {
return {keyboardSpace: 0};
},
updateKeyboardSpace: function(frames) {
LayoutAnimation.configureNext(animations.layout.spring);
this.setState({keyboardSpace: frames.end.height});
},
resetKeyboardSpace: function() {
LayoutAnimation.configureNext(animations.layout.spring);
this.setState({keyboardSpace: 0});
},
componentDidMount: function() {
KeyboardEventEmitter.on(KeyboardEvents.KeyboardDidShowEvent, this.updateKeyboardSpace);
KeyboardEventEmitter.on(KeyboardEvents.KeyboardWillHideEvent, this.resetKeyboardSpace);
},
componentWillUnmount: function() {
KeyboardEventEmitter.off(KeyboardEvents.KeyboardDidShowEvent, this.updateKeyboardSpace);
KeyboardEventEmitter.off(KeyboardEvents.KeyboardWillHideEvent, this.resetKeyboardSpace);
},
Bazı örnek animasyonlar (yukarıdaki yayı kullanıyorum):
var animations = {
layout: {
spring: {
duration: 400,
create: {
duration: 300,
type: LayoutAnimation.Types.easeInEaseOut,
property: LayoutAnimation.Properties.opacity,
},
update: {
type: LayoutAnimation.Types.spring,
springDamping: 400,
},
},
easeInEaseOut: {
duration: 400,
create: {
type: LayoutAnimation.Types.easeInEaseOut,
property: LayoutAnimation.Properties.scaleXY,
},
update: {
type: LayoutAnimation.Types.easeInEaseOut,
},
},
},
};
GÜNCELLEME:
Aşağıdaki @ sherlock'un cevabına bakın, react-native 0.11'den itibaren klavyenin yeniden boyutlandırılması yerleşik işlevsellik kullanılarak çözülebilir.