mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-01 22:25:12 +00:00
add touchable support for shape elements
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import {Component} from 'react';
|
||||
import extractProps from '../lib/extract/extractProps';
|
||||
import SvgTouchableMixin from '../lib/SvgTouchableMixin';
|
||||
import _ from 'lodash';
|
||||
|
||||
class Shape extends Component {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
_.forEach(SvgTouchableMixin, (method, key) => {
|
||||
this[key] = method.bind(this);
|
||||
});
|
||||
this.state = this.touchableGetInitialState();
|
||||
}
|
||||
|
||||
extractProps = (props) => {
|
||||
let extractedProps = extractProps(props);
|
||||
if (extractedProps.touchable && !extractedProps.disabled) {
|
||||
_.assign(extractedProps, {
|
||||
onStartShouldSetResponder: this.touchableHandleStartShouldSetResponder,
|
||||
onResponderTerminationRequest: this.touchableHandleResponderTerminationRequest,
|
||||
onResponderGrant: this.touchableHandleResponderGrant,
|
||||
onResponderMove: this.touchableHandleResponderMove,
|
||||
onResponderRelease: this.touchableHandleResponderRelease,
|
||||
onResponderTerminate: this.touchableHandleResponderTerminate
|
||||
});
|
||||
}
|
||||
|
||||
return extractedProps;
|
||||
}
|
||||
}
|
||||
|
||||
export default Shape;
|
||||
Reference in New Issue
Block a user