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

Conical gradient support #41

Open
fdnhkj opened this issue Oct 18, 2016 · 30 comments
Open

Conical gradient support #41

fdnhkj opened this issue Oct 18, 2016 · 30 comments

Comments

@fdnhkj
Copy link
Contributor

fdnhkj commented Oct 18, 2016

It would be nice to have support for conical gradient.
Has anyone an idea on how to implement it ?

colorgradient

@GroupXTech
Copy link

Any luck on finding your conical gradient... I need that in a slider as well

@morelazers
Copy link

Yes I'm looking for something similar, I want to animate the colour of the fill.

I can get it to work by removing the validation of PropTypes.string but it is incredibly slow.

@bartgryszko
Copy link
Owner

@fdnhkj Cannonical gradients aren't supported in SVG. In my other component (https://github.com/bgryszko/react-native-circular-slider) I achieve exactly what you're looking for by splitting circle into segments and draw small linear gradients – in practice if gradient colors difference is subtle or there are enough "segments" it'll look as if it's cannonical gradient.

Link to specific code:
https://github.com/bgryszko/react-native-circular-slider/blob/master/src/CircularSlider.js#L161-L168

@fdnhkj
Copy link
Contributor Author

fdnhkj commented Jan 7, 2017

Indeed, I forgot to update this issue with my findings, I'll try to find back my repo & share it.

Basically I switched to react-native-svg and as you mentioned splited the circle in multiple segments with attached linear gradients (see http://jsfiddle.net/Cy7ec/3/).

The conical gradient was looking fine on both iOS & Android but I had quite some issues with the Android animations (lots of dropped fps).

It's maybe worth trying with the latest versions of react-native & react-native-svg.
I will give you updates ASAP.

@bartgryszko
Copy link
Owner

bartgryszko commented Jan 8, 2017 via email

@fdnhkj
Copy link
Contributor Author

fdnhkj commented Jan 9, 2017

Voilà, I published my findings after upgrading to latest react-native and react-native-svg in fdnhkj/react-native-conical-gradient.

It looks like there are some dropped fps. I don't really see how to improve it tho, suggestions are welcome 🙂


Fidan

@bartgryszko
Copy link
Owner

I'm happy to accept PR if anybody would be able to merge this into main lib.

@zoharlevin
Copy link

+1

2 similar comments
@t2krew
Copy link

t2krew commented Mar 14, 2017

+1

@rodrigooler
Copy link

+1

@valerybodak
Copy link

valerybodak commented Jun 12, 2017

@fdnhkj
How to make it spin in the opposite direction? (like in the first your post)

@NeXTs
Copy link

NeXTs commented Aug 30, 2017

@fdnhkj based on this research the only possible solution to improve FPS is using canvas instead of svg

@robert-stevens
Copy link

+1

@MikePodgorniy
Copy link

@bartgryszko I can try add this feature, into react-native-circular-progress.
I updated @fdnhkj example with some changes and I have ideas how to increase perfomance with smooth gradient on the screen.

@hanishcodebrew
Copy link

hanishcodebrew commented Dec 5, 2018

@fdnhkj How to make it spin in the opposite direction? i.e clockwise instead of anticlockwise

@MikePodgorniy
Copy link

@hanishcodebrew you can wrap component into

<View style={ { transform: [ { scaleX: -1 }] } }>

or use similar code
https://github.com/MikePodgorniy/react-native-conical-gradient-progress/blob/de35329780ed6431ff21710dc8a6c69b639263e8/CircularProgress.js#L175-L183

@hanishcodebrew
Copy link

hanishcodebrew commented Dec 5, 2018

Thanks @MikePodgorniy for the instant reply. It works. I am facing a issue in Android.
screen shot 2018-12-05 at 1 14 52 pm

I have given 45 to fill but its showing complete circle. And also can we add image and text inside the circle ?

@bartgryszko
Copy link
Owner

bartgryszko commented Dec 5, 2018

@MikePodgorniy I'm not actively participating in developing this library as I'm not working on any RN project currently. That said, feel free to add PR, if not me, maybe @Jacse or @markusl would be able to review and merge it.

@MikePodgorniy
Copy link

@hanishcodebrew yes, you can 👍 use render callback to this. but you need to rescale your inner components again
https://github.com/MikePodgorniy/react-native-conical-gradient-progress/blob/de35329780ed6431ff21710dc8a6c69b639263e8/example/App.js#L25-L32

@Angelk90
Copy link

Angelk90 commented Jan 18, 2019

@fdnhkj,@GroupXTech,@morelazers,@bartgryszko,@fdnhkj,@NeXTs,@MikePodgorniy,@hanishcodebrew :
I wanted to know how it ended, it also served me.

@fdnhkj: Your module react-native-conical-gradient, I do not find it on npm you can upload it, can you also put an example code?

@MikePodgorniy: Your module react-native-conical-gradient-progress, I do not find it on npm you can upload it, can you also put an example code?

For both:
The sample code of the images of your modules would be a step forward.

An example that can also be tried on snack.expo.io, would be very ideal.

@MikePodgorniy
Copy link

@Angelk90 Try now, it is available as an npm-package:
https://www.npmjs.com/package/react-native-conical-gradient-progress.

You can find an example here – https://github.com/MikePodgorniy/react-native-conical-gradient-progress/tree/master/example

if you use clear react-native you should install react-native-svg.

@Angelk90
Copy link

@MikePodgorniy : I do not understand why among the dependencies you did not put svg in the package.json?

@Angelk90
Copy link

@MikePodgorniy : I tried to convert your module to try it on https://snack.expo.io/
I am given the following error:
TypeError: undefined is not an object (evaluating 'o.map')
Line 27 of CircularProgress:
Here is the link where you can try it: https://snack.expo.io/HkDheSJmE

@MikePodgorniy
Copy link

MikePodgorniy commented Jan 18, 2019

@Angelk90
Thank you, I will check this issue later.
I tested component with expo local. If you want we can continue discussing there https://github.com/MikePodgorniy/react-native-conical-gradient-progress

@Angelk90
Copy link

Angelk90 commented Jan 18, 2019

@MikePodgorniy : Do not allow me to create issues in the indicated project.
It's because your project is a fork.

@MikePodgorniy
Copy link

@Angelk90 sorry, try again

@Angelk90
Copy link

@MikePodgorniy : I answered you in your project, I look forward to your response.

@ngnclht1102
Copy link

Voilà, I published my findings after upgrading to latest react-native and react-native-svg in fdnhkj/react-native-conical-gradient.

It looks like there are some dropped fps. I don't really see how to improve it tho, suggestions are welcome 🙂


Fidan

I have the same problem as well, the UI's fps is dropped to 2x. Any ideas on how to improve it?

@thanakij
Copy link

I have been doing something similar. My approach uses "LinearGradient" react-native-svg.

You can give it a try by:

npm install react-native-circular-progress-gradient@1.3.8

You will need to add tintColorSecondary prop to trigger the gradient mode.

@minafa96
Copy link

I have been doing something similar. My approach uses "LinearGradient" react-native-svg.

You can give it a try by:

npm install react-native-circular-progress-gradient@1.3.8

You will need to add tintColorSecondary prop to trigger the gradient mode.

GREAT, THANK YOU! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests