iOS标记动画的持续时间无法正常工作

问题描述 投票:0回答:1

iOS动画中的持续时间变量似乎未从默认的500ms更改持续时间

[许多示例都显示这是更改持续时间的方法,但是当我更改持续时间值时,无论持续时间值如何,它似乎都保持500ms。

import Mapview, { AnimatedRegion, Marker } from 'react-native-maps';

getInitialState() {

    return {
    coordinate: new AnimatedRegion({
      latitude: LATITUDE,
      longitude: LONGITUDE,
    }),
  };
}

componentWillReceiveProps(nextProps) {
  const duration = 5000

  if (this.props.coordinate !== nextProps.coordinate) {
    if (Platform.OS === 'android') {
      if (this.marker) {
        this.marker._component.animateMarkerToCoordinate(
          nextProps.coordinate,
          duration
        );
      }
    } else {
      this.state.coordinate.timing({
        ...nextProps.coordinate,
        duration
      }).start();
    }
  }
}

render() {
  return (
    <MapView initialRegion={...}>
      <MapView.Marker.Animated
        ref={marker => { this.marker = marker }}
        coordinate={this.state.coordinate}
      />
    </MapView>
  );
}

我希望动画在此示例中花费5秒钟,但需要500毫秒。

reactjs react-native react-native-maps
1个回答
0
投票

您解决了吗?,我有同样的问题

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.