/
Demo3.js
63 lines (54 loc) · 1.3 KB
/
Demo3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import React from 'react';
import {
View,
StyleSheet
} from 'react-native';
import {Slider} from '../index';
export class Demo3 extends React.PureComponent {
tipFormatter1 = val => `${val}%`;
tipFormatter2 = val => `$ ${val}`;
onBeginSliding = () => {
const {getSvRef} = this.props;
const svRef = getSvRef();
svRef && svRef.setNativeProps({scrollEnabled: false});
}
onEndSliding = () => {
const {getSvRef} = this.props;
const svRef = getSvRef();
svRef && svRef.setNativeProps({scrollEnabled: true});
}
render() {
return (
<View style={styles.container}>
<Slider
min={0}
max={100}
defaultValue={30}
style={styles.slider}
tipFormatter={this.tipFormatter1}
onBeginSliding={this.onBeginSliding}
onEndSliding={this.onEndSliding}
/>
<Slider
min={0}
max={100}
defaultValue={70}
style={styles.slider}
tipFormatter={this.tipFormatter2}
onBeginSliding={this.onBeginSliding}
onEndSliding={this.onEndSliding}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
justifyContent: 'center',
paddingHorizontal: 30,
height: 150
},
slider: {
marginVertical: 15
}
});