Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed strokeDasharray failed to use animation with "useNativeDriver: true" attribute. #1464

Closed

Conversation

bardliu
Copy link

@bardliu bardliu commented Sep 29, 2020

Summary

  1. Fixes #55#issuecomment-241074767
    Please see this issue #55#issuecomment-241074767

  2. I got an error like String canot be cast to ReadableArray for strokeDasharray.
    721601361053_ pic_hd

  3. strokeDasharray doesn't need extractLengthList.

What are the steps to reproduce (after prerequisites)?

const AnimatedCircle = Animated.createAnimatedComponent(Circle);
this.animatedValue = new Animated.Value(0);
Animated.loop(
    Animated.timing(this.animatedValue, {
    toValue: 100,
    duration: 1250,
    easing: Easing.linear,
    useNativeDriver: true,
    }),
 ).start();

<AnimatedCircle
    cx="15"
    cy="15"
    r="13"
    stroke={color}
    strokeWidth="2.5"
    strokeLinecap="round"
    strokeDasharray={this.animatedValue.interpolate({
    inputRange: [0, 50, 100],
    outputRange: [
        '8.1681408993,73.513268094',
        '40.8407044967,40.8407045967',
        '8.1681408993,73.513268094',
        ],
     })}
     fill="none"
/>

Compatibility

OS Implemented
iOS
Android

Checklist

  • I have tested this on a device and a simulator

…true" attribute.

like
```
	<AnimatedCircle
                cx="15"
                cy="15"
                r="13"
                stroke={color}
                strokeWidth="2.5"
                strokeLinecap="round"
                strokeDasharray={this.animatedValue.interpolate({
                  inputRange: [0, 50, 100],
                  outputRange: [
                    '8.1681408993,73.513268094',
                    '40.8407044967,40.8407045967',
                    '8.1681408993,73.513268094',
                  ],
                })}
                fill="none"
              />
```
@ouoru
Copy link

ouoru commented Aug 25, 2021

this works well for me :) thanks for your contributions - even if they aren't being merged.

are the ios changes necessary? I noticed animated strokeDashArray is already working for me on ios.

@bardliu
Copy link
Author

bardliu commented Dec 15, 2021

this works well for me :) thanks for your contributions - even if they aren't being merged.

are the ios changes necessary? I noticed animated strokeDashArray is already working for me on ios.

It is suggested to change together.

@pavel-stryber
Copy link

pavel-stryber commented Jul 6, 2023

I'm wonder why guys who support this library don't want to merge this solution? It is passed 3-years and we still struggling with a way how to make svg animatable on Android.

WoLewicki added a commit that referenced this pull request Jul 7, 2023
PR adding the proper handling of strokeDasharray prop for when used with Animated and Reanimated. Code based on #1464 by @bardliu, but with the newest state of the repository.
@WoLewicki
Copy link
Member

Closing since #2089 has been merged. Thanks for your contribution 🚀

@WoLewicki WoLewicki closed this Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Animation
5 participants