Skip to content

Commit e488202

Browse files
authored
Merge pull request halilb#42 from Grivel-l/nativeDrivers
Native drivers support added for Kohana
2 parents d40823b + d9bc64c commit e488202

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ const kohanaInput = (
118118
iconColor={'#f4d29a'}
119119
labelStyle={{ color: '#91627b' }}
120120
inputStyle={{ color: '#91627b' }}
121+
useNativeDriver={true}
121122
/>
122123
);
123124
```

lib/BaseInput.js

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export default class BaseInput extends Component {
101101
toValue: isActive ? 1 : 0,
102102
duration: this.props.animationDuration,
103103
easing: this.props.easing,
104+
useNativeDriver: this.useNativeDriver || false
104105
}).start();
105106
}
106107

lib/Kohana.js

+18-9
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default class Kohana extends BaseInput {
3838
static defaultProps = {
3939
easing: Easing.bezier(0.2, 1, 0.3, 1),
4040
iconSize: 25,
41+
useNativeDriver: false
4142
};
4243

4344
render() {
@@ -63,10 +64,12 @@ export default class Kohana extends BaseInput {
6364
style={{
6465
justifyContent: 'center',
6566
padding: PADDING,
66-
marginLeft: focusedAnim.interpolate({
67-
inputRange: [0, 1],
68-
outputRange: [-15 - iconSize, 0],
69-
}),
67+
transform: [{
68+
translateX: focusedAnim.interpolate({
69+
inputRange: [0, 1],
70+
outputRange: [-15 - iconSize, 0],
71+
})
72+
}],
7073
}}
7174
>
7275
<Icon name={iconName} color={iconColor} size={iconSize} />
@@ -77,10 +80,13 @@ export default class Kohana extends BaseInput {
7780
style={{
7881
position: 'absolute',
7982
top: PADDING,
80-
left: focusedAnim.interpolate({
81-
inputRange: [0, 1],
82-
outputRange: [PADDING, 80],
83-
}),
83+
left: 0,
84+
transform: [{
85+
translateX: focusedAnim.interpolate({
86+
inputRange: [0, 1],
87+
outputRange: [PADDING, 80],
88+
})
89+
}],
8490
opacity: focusedAnim.interpolate({
8591
inputRange: [0, 1],
8692
outputRange: [1, 0],
@@ -98,7 +104,10 @@ export default class Kohana extends BaseInput {
98104
style={[styles.textInput, inputStyle]}
99105
value={value}
100106
onBlur={this._onBlur}
101-
onFocus={this._onFocus}
107+
onFocus={event => {
108+
this.useNativeDriver = this.props.useNativeDriver;
109+
this._onFocus(event);
110+
}}
102111
onChange={this._onChange}
103112
underlineColorAndroid={'transparent'}
104113
/>

0 commit comments

Comments
 (0)