Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ var propTypes = {
style: View.propTypes.style,
}

const cleanStyle = {
fontSize: 20,
top: 7
};

const dirtyStyle = {
fontSize: 12,
top: -17
};

var FloatingLabel = React.createClass({
propTypes: propTypes,

Expand All @@ -31,7 +41,10 @@ var FloatingLabel = React.createClass({
dirty: !!this.props.value
};

var style = state.dirty ? dirtyStyle : cleanStyle
this.cleanStyle = this.props.cleanStyle ? this.props.cleanStyle : cleanStyle;
this.dirtyStyle = this.props.dirtyStyle ? this.props.dirtyStyle : dirtyStyle;

var style = state.dirty ? this.dirtyStyle : this.cleanStyle
state.labelStyle = {
fontSize: new Animated.Value(style.fontSize),
top: new Animated.Value(style.top)
Expand All @@ -48,7 +61,7 @@ var FloatingLabel = React.createClass({
},

_animate(dirty) {
var nextStyle = dirty ? dirtyStyle : cleanStyle
var nextStyle = dirty ? this.dirtyStyle : this.cleanStyle
var labelStyle = this.state.labelStyle
var anims = Object.keys(nextStyle).map(prop => {
return Animated.timing(
Expand Down Expand Up @@ -194,16 +207,6 @@ var styles = StyleSheet.create({
label: labelStyleObj
})

var cleanStyle = {
fontSize: 20,
top: 7
}

var dirtyStyle = {
fontSize: 12,
top: -17,
}

FloatingLabel.propTypes = {
disabled: PropTypes.bool,
style: Text.propTypes.style,
Expand Down