当用户按下按钮时,我在图像上使用 Animated 以编程方式缩放图像。
handleZoomIn() {
this.zoom += -0.25;
Animated.spring(this.animatedValue, {
toValue: this.zoom
}).start() }
handleZoomOut() {
this.zoom += 0.25;
Animated.spring(this.animatedValue, {
toValue: this.zoom,
friction: 3,
tension: 40
}).start() }
const imageStyle = {
transform: [{ scale: this.animatedValue}]
}
render() {
<Animated.Image source={{ uri: source }} style={[imgSize, { position: 'absolute' }, imageStyle]} />
}
如何计算两个图像左上角之间的距离?
偏移量不应该是吗?
(dx, dy) = ((originalWidth-(originalWidth X scale))/2, (originalWidth - (originalHeight X scale))/2)