React Native Map (Airbnb) + 标记动画
React Native Map (Airbnb) + Markers animation
我想为 React-native-maps {Google} 标记设置动画。
我试过动画模块,但是标记不允许复杂的样式。
有没有修改marker坐标和动画的功能,比如:
marker.setAnimation(google.maps.Animation.BOUNCE);
我试过:
<MapView.Marker.Animated>
但是我无法创建效果。有没有把坐标编辑成动画掉落的功能?
React原生地图标记默认为"not animated",不接受gif图片,精灵,动画api等。 .但是,我能够通过图像转换以艰难的方式为其设置动画。这是我的例子:
constructor(props, context) {
super(props, context);
this.state = {
startTransition: 1,
endTransition: 4,
};
}
componentDidMount() {
this.animate();
}
animate() {
const {startTransition, endTransition} = this.state;
if(startTransition < endTransition){
let currentTransition = startTransition + 1;
this.setState({startTransition: currentTransition});
} else {
this.setState({startTransition: 1});
}
let x = setTimeout(()=>{
this.animate()
}, 500);
}
renderImg(imgTrans) {
if(imgTrans === 1) {
return require('./walk1.png');
}
if(imgTrans === 2) {
return require('./walk2.png');
}
if(imgTrans === 3) {
return require('./walk3.png');
}
if(imgTrans === 4) {
return require('./walk4.png');
}
}
render() {
const {startTransition} = this.state;
return (
<MapView.Marker
coordinate={tapCoords}
image={this.renderImg(startTransition)}
>
)
}
这就是我现在制作动画的方式。
我想为 React-native-maps {Google} 标记设置动画。
我试过动画模块,但是标记不允许复杂的样式。
有没有修改marker坐标和动画的功能,比如:
marker.setAnimation(google.maps.Animation.BOUNCE);
我试过:
<MapView.Marker.Animated>
但是我无法创建效果。有没有把坐标编辑成动画掉落的功能?
React原生地图标记默认为"not animated",不接受gif图片,精灵,动画api等。 .但是,我能够通过图像转换以艰难的方式为其设置动画。这是我的例子:
constructor(props, context) {
super(props, context);
this.state = {
startTransition: 1,
endTransition: 4,
};
}
componentDidMount() {
this.animate();
}
animate() {
const {startTransition, endTransition} = this.state;
if(startTransition < endTransition){
let currentTransition = startTransition + 1;
this.setState({startTransition: currentTransition});
} else {
this.setState({startTransition: 1});
}
let x = setTimeout(()=>{
this.animate()
}, 500);
}
renderImg(imgTrans) {
if(imgTrans === 1) {
return require('./walk1.png');
}
if(imgTrans === 2) {
return require('./walk2.png');
}
if(imgTrans === 3) {
return require('./walk3.png');
}
if(imgTrans === 4) {
return require('./walk4.png');
}
}
render() {
const {startTransition} = this.state;
return (
<MapView.Marker
coordinate={tapCoords}
image={this.renderImg(startTransition)}
>
)
}
这就是我现在制作动画的方式。