react-native-view-transformer
Advanced tools
Comparing version 0.0.14 to 0.0.15
@@ -24,3 +24,2 @@ 'use strict'; | ||
constructor(props) { | ||
@@ -50,5 +49,3 @@ super(props); | ||
this.onLayout = this.onLayout.bind(this); | ||
this.handleScroll = this.handleScroll.bind(this); | ||
this.handleMove = this.handleMove.bind(this); | ||
@@ -88,10 +85,2 @@ this.handleRelease = this.handleRelease.bind(this); | ||
componentDidUpdate(prevProps, prevState) { | ||
this.props.onViewTransformed && this.props.onViewTransformed({ | ||
scale: this.state.scale, | ||
translateX: this.state.translateX, | ||
translateY: this.state.translateY | ||
}); | ||
} | ||
render() { | ||
@@ -107,6 +96,4 @@ let gestureResponder = this.gestureResponder; | ||
{...gestureResponder} | ||
style={[this.props.style, {overflow: 'visible'}]}> | ||
ref={'innerViewRef'}> | ||
<View | ||
ref={'innerViewRef'} | ||
onLayout={this.onLayout} | ||
style={{ | ||
@@ -118,3 +105,3 @@ flex: 1, | ||
{translateY: this.state.translateY} | ||
], | ||
] | ||
}}> | ||
@@ -124,3 +111,2 @@ {this.props.children} | ||
</View> | ||
); | ||
@@ -132,3 +118,3 @@ } | ||
onStartShouldSetResponder: (evt, gestureState) => { | ||
this.onLayout(); | ||
this.measureLayout(); | ||
return true; | ||
@@ -149,10 +135,22 @@ }, | ||
componentDidMount() { | ||
this.measureLayout(); | ||
} | ||
componentDidUpdate(prevProps, prevState) { | ||
this.props.onViewTransformed && this.props.onViewTransformed({ | ||
scale: this.state.scale, | ||
translateX: this.state.translateX, | ||
translateY: this.state.translateY | ||
}); | ||
} | ||
componentWillUnmount() { | ||
console.log('componentWillUnmount...'); | ||
this.cancelAnimation(); | ||
} | ||
onLayout(e) { | ||
measureLayout() { | ||
let handle = ReactNative.findNodeHandle(this.refs['innerViewRef']); | ||
NativeModules.UIManager.measure(handle, ((x, y, width, height, pageX, pageY) => { | ||
console.log('measure...pageX=' + pageX + ', pageY=' + pageY); | ||
this.setState({ | ||
@@ -373,3 +371,3 @@ width: width, | ||
this.state.animator.setValue(0); | ||
this.state.animator.addListener(function (state) { | ||
this.state.animator.addListener((state) =>{ | ||
let progress = state.value; | ||
@@ -385,3 +383,4 @@ | ||
this.updateTransform(transform); | ||
}.bind(this)); | ||
}); | ||
Animated.timing(this.state.animator, { | ||
@@ -428,3 +427,3 @@ toValue: 1, | ||
setTransform(transform) { | ||
forceUpdateTransform(transform) { | ||
this.setState(transform); | ||
@@ -431,0 +430,0 @@ } |
{ | ||
"name": "react-native-view-transformer", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "`react-native-view-transformer` is a pure JavaScript RN component that makes **ANY** views transformable using gestures like pinch, double tap or pull, as below shows:", | ||
@@ -5,0 +5,0 @@ "main": "library/index.js", |
31090