1+ import React , { Component } from 'react'
2+ import Touchable from './vendor/Touchable'
3+ import Animated from 'animated/lib/targets/react-dom'
4+
5+ export default class AnimatedView extends Component {
6+ constructor ( props ) {
7+ super ( props )
8+ this . state = this . touchableGetInitialState ( )
9+ }
10+
11+ /**
12+ * `Touchable.Mixin` self callbacks. The mixin will invoke these if they are
13+ * defined on your component.
14+ */
15+ touchableHandlePress ( e ) {
16+ this . props . onPress && this . props . onPress ( e ) ;
17+ }
18+
19+ touchableHandleActivePressIn ( e ) {
20+ this . props . onPressIn && this . props . onPressIn ( e ) ;
21+ }
22+
23+ touchableHandleActivePressOut ( e ) {
24+ this . props . onPressOut && this . props . onPressOut ( e ) ;
25+ }
26+
27+ touchableHandleLongPress ( e ) {
28+ this . props . onLongPress && this . props . onLongPress ( e ) ;
29+ }
30+
31+ touchableGetPressRectOffset ( ) {
32+ return this . props . pressRetentionOffset || PRESS_RETENTION_OFFSET ;
33+ }
34+
35+ touchableGetHitSlop ( ) {
36+ return this . props . hitSlop ;
37+ }
38+
39+ touchableGetHighlightDelayMS ( ) {
40+ return this . props . delayPressIn || 0 ;
41+ }
42+
43+ touchableGetLongPressDelayMS ( ) {
44+ return this . props . delayLongPress === 0 ? 0 : this . props . delayLongPress || 500 ;
45+ }
46+
47+ touchableGetPressOutDelayMS ( ) {
48+ return this . props . delayPressOut || 0 ;
49+ }
50+
51+ render ( ) {
52+ const {
53+ /* eslint-disable */
54+ delayLongPress,
55+ delayPressIn,
56+ delayPressOut,
57+ onLongPress,
58+ onPress,
59+ onPressIn,
60+ onPressOut,
61+ pressRetentionOffset,
62+ /* eslint-enable */
63+ ...other
64+ } = this . props ;
65+
66+ return (
67+ < Animated . div { ...other }
68+ accessible = { this . props . accessible !== false }
69+ onKeyDown = { this . touchableHandleKeyEvent }
70+ onKeyUp = { this . touchableHandleKeyEvent }
71+ onResponderGrant = { this . touchableHandleResponderGrant }
72+ onResponderMove = { this . touchableHandleResponderMove }
73+ onResponderRelease = { this . touchableHandleResponderRelease }
74+ onResponderTerminate = { this . touchableHandleResponderTerminate }
75+ onResponderTerminationRequest = { this . touchableHandleResponderTerminationRequest }
76+ onStartShouldSetResponder = { this . touchableHandleStartShouldSetResponder } >
77+ { this . props . children }
78+ </ Animated . div >
79+ )
80+
81+ return React . cloneElement ( this . props . children , {
82+ ...other ,
83+ accessible : this . props . accessible !== false ,
84+ children,
85+ onKeyDown : this . touchableHandleKeyEvent ,
86+ onKeyUp : this . touchableHandleKeyEvent ,
87+ onResponderGrant : this . touchableHandleResponderGrant ,
88+ onResponderMove : this . touchableHandleResponderMove ,
89+ onResponderRelease : this . touchableHandleResponderRelease ,
90+ onResponderTerminate : this . touchableHandleResponderTerminate ,
91+ onResponderTerminationRequest : this . touchableHandleResponderTerminationRequest ,
92+ onStartShouldSetResponder : this . touchableHandleStartShouldSetResponder ,
93+ style
94+ } ) ;
95+ }
96+ }
0 commit comments