react-native-keyboard-spacer
Advanced tools
Comparing version 0.1.6 to 0.2.0
/** | ||
* Created by andrewhurst on 10/5/15. | ||
*/ | ||
var React = require('react-native'); | ||
var React = require('react'); | ||
var ReactNative = require('react-native'); | ||
@@ -9,32 +10,17 @@ var { | ||
LayoutAnimation, | ||
View, | ||
View, | ||
Platform | ||
} = React; | ||
} = ReactNative; | ||
// From: https://medium.com/man-moon/writing-modern-react-native-ui-e317ff956f02 | ||
const animations = { | ||
layout: { | ||
spring: { | ||
duration: 500, | ||
create: { | ||
duration: 300, | ||
type: LayoutAnimation.Types.easeInEaseOut, | ||
property: LayoutAnimation.Properties.opacity | ||
}, | ||
update: { | ||
type: LayoutAnimation.Types.spring, | ||
springDamping: 200 | ||
} | ||
}, | ||
easeInEaseOut: { | ||
duration: 300, | ||
create: { | ||
type: LayoutAnimation.Types.easeInEaseOut, | ||
property: LayoutAnimation.Properties.scaleXY | ||
}, | ||
update: { | ||
delay: 100, | ||
type: LayoutAnimation.Types.easeInEaseOut | ||
} | ||
} | ||
const defaultAnimation = { | ||
duration: 500, | ||
create: { | ||
duration: 300, | ||
type: LayoutAnimation.Types.easeInEaseOut, | ||
property: LayoutAnimation.Properties.opacity | ||
}, | ||
update: { | ||
type: LayoutAnimation.Types.spring, | ||
springDamping: 200 | ||
} | ||
@@ -56,4 +42,5 @@ }; | ||
componentWillUpdate(props, state) { | ||
if (state.isKeyboardOpened !== this.state.isKeyboardOpened) | ||
LayoutAnimation.configureNext(animations.layout.spring); | ||
if (state.isKeyboardOpened !== this.state.isKeyboardOpened) { | ||
LayoutAnimation.configureNext(props.animationConfig || defaultAnimation); | ||
} | ||
} | ||
@@ -64,4 +51,4 @@ | ||
return; | ||
var keyboardSpace = frames.endCoordinates.height + ('topSpacing' in this.props ? this.props.topSpacing : 0); | ||
var keyboardSpace = frames.endCoordinates.height + ('topSpacing' in this.props ? this.props.topSpacing : 0); | ||
this.setState({ | ||
@@ -85,3 +72,3 @@ keyboardSpace: keyboardSpace, | ||
DeviceEventEmitter.addListener('keyboardDidHide', this.resetKeyboardSpace) | ||
]; | ||
]; | ||
} else { | ||
@@ -88,0 +75,0 @@ this._listeners = [ |
{ | ||
"name": "react-native-keyboard-spacer", | ||
"version": "0.1.6", | ||
"version": "0.2.0", | ||
"description": "Plug and play react-Native keyboard spacer view.", | ||
@@ -5,0 +5,0 @@ "main": "KeyboardSpacer.js", |
@@ -53,2 +53,3 @@ [![NPM](https://nodei.co/npm-dl/react-native-keyboard-spacer.png?months=3&height=2)](https://nodei.co/npm/react-native-keyboard-spacer/) | ||
| topSpacing | 0 | `number` | Add or subtract additional spacing from keyboard height | | ||
| animationConfig | [A default animation](https://github.com/Andr3wHur5t/react-native-keyboard-spacer/blob/expose-layout-animations/KeyboardSpacer.js#L14) | `LayoutAnimationConfig` | [LayoutAnimation](https://facebook.github.io/react-native/docs/layoutanimation.html#content) configuration object | | ||
@@ -55,0 +56,0 @@ ### Properties - Methods |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60
6730
77