最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Animating the border radius in React Native - Stack Overflow

programmeradmin3浏览0评论

I'm unable to animate the borderRadius property in a ReactNative Image, it seems to only re-render the image as the animation pletes. It fades out on animation start, and fades back in on animation pletion. This only happens on Android; on iOS the animation plays properly.

I am trying to animate a circle expanding into a square by animating the borderRadius:

constructor(props) {
    super(props);
    this.state = {
        borderRadius: new Animated.Value(ALBUM_CIRCLE_DIAMETER /2)
    };
}

_zoomIn = () => {
    Animated.timing(
        this.state.borderRadius,
        {
            toValue: 0,
            duration: ZOOM_ANIMATION_DURATION_MS,
            easing: Easing.linear
        }
    ).start()
}

And the markup:

<Animated.Image
    style={[
        styles.albumArtCircle,
        { width: this.state.albumArtWidth },
        { height: this.state.albumArtHeight },
        { borderRadius: this.state.borderRadius },
    ]}
    resizeMode='contain'
    source={require('../images/sampleAlbum.jpg')}>
</Animated.Image>

I'm unable to animate the borderRadius property in a ReactNative Image, it seems to only re-render the image as the animation pletes. It fades out on animation start, and fades back in on animation pletion. This only happens on Android; on iOS the animation plays properly.

I am trying to animate a circle expanding into a square by animating the borderRadius:

constructor(props) {
    super(props);
    this.state = {
        borderRadius: new Animated.Value(ALBUM_CIRCLE_DIAMETER /2)
    };
}

_zoomIn = () => {
    Animated.timing(
        this.state.borderRadius,
        {
            toValue: 0,
            duration: ZOOM_ANIMATION_DURATION_MS,
            easing: Easing.linear
        }
    ).start()
}

And the markup:

<Animated.Image
    style={[
        styles.albumArtCircle,
        { width: this.state.albumArtWidth },
        { height: this.state.albumArtHeight },
        { borderRadius: this.state.borderRadius },
    ]}
    resizeMode='contain'
    source={require('../images/sampleAlbum.jpg')}>
</Animated.Image>
Share Improve this question asked Jan 18, 2017 at 15:04 MatBeeMatBee 2846 silver badges17 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

Right! Remove resizeMode property. This will solve your problem

Removing resizeMode='contain' made this work.

发布评论

评论列表(0)

  1. 暂无评论