Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class MyScene extends PureComponent {
/**
* Positioning
*/
shouldCenterAllExpanded: PropTypes.bool,
positionRightDelete: PropTypes.number,
searchIconCollapsedMargin: PropTypes.number,
searchIconExpandedMargin: PropTypes.number,
Expand All @@ -221,6 +222,7 @@ class MyScene extends PureComponent {

## Prop Defaults
```
shouldCenterAllExpanded: true,
searchIconCollapsedMargin: 25,
searchIconExpandedMargin: 10,
placeholderCollapsedMargin: 15,
Expand Down
18 changes: 14 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ class Search extends PureComponent {
* Animated values
*/
this.iconSearchAnimated = new Animated.Value(
this.middleWidth - this.props.searchIconCollapsedMargin
this.props.shouldCenterAllExpanded
? this.middleWidth - this.props.searchIconCollapsedMargin
: this.props.searchIconCollapsedMargin
);
this.iconDeleteAnimated = new Animated.Value(0);
this.inputFocusWidthAnimated = new Animated.Value(this.contentWidth - 10);
this.inputFocusPlaceholderAnimated = new Animated.Value(
this.middleWidth - this.props.placeholderCollapsedMargin
this.props.shouldCenterAllExpanded
? this.middleWidth - this.props.placeholderCollapsedMargin
: this.props.placeholderCollapsedMargin
);
this.btnCancelAnimated = new Animated.Value(this.contentWidth);

Expand Down Expand Up @@ -225,13 +229,17 @@ class Search extends PureComponent {
}).start(),
this.props.keyboardShouldPersist === false
? Animated.timing(this.inputFocusPlaceholderAnimated, {
toValue: this.middleWidth - this.props.placeholderCollapsedMargin,
toValue: this.props.shouldCenterAllExpanded
? this.middleWidth - this.props.placeholderCollapsedMargin
: this.props.placeholderCollapsedMargin,
duration: 200
}).start()
: null,
this.props.keyboardShouldPersist === false || isForceAnim === true
? Animated.timing(this.iconSearchAnimated, {
toValue: this.middleWidth - this.props.searchIconCollapsedMargin,
toValue: this.props.shouldCenterAllExpanded
? this.middleWidth - this.props.searchIconCollapsedMargin
: this.props.searchIconCollapsedMargin,
duration: 200
}).start()
: null,
Expand Down Expand Up @@ -536,6 +544,7 @@ Search.propTypes = {
/**
* Positioning
*/
shouldCenterAllExpanded: PropTypes.bool,
positionRightDelete: PropTypes.number,
searchIconCollapsedMargin: PropTypes.number,
searchIconExpandedMargin: PropTypes.number,
Expand All @@ -559,6 +568,7 @@ Search.defaultProps = {
editable: true,
blurOnSubmit: true,
keyboardShouldPersist: false,
shouldCenterAllExpanded: true,
searchIconCollapsedMargin: 25,
searchIconExpandedMargin: 10,
placeholderCollapsedMargin: 15,
Expand Down