Comments (5)
2 years too late, but thanks for the inspiration @nuttylord! The onLayout
method on View
is triggered when the key changes, so I updated changed the following element in CircularSlider.js
to:
<View key={scrollY} style={...} onLayout={this.onLayout}>
I also added a PropType
of number for scrollY
, which I'm passing directly into the <CircularSlider scrollY={...}
component where I'm calling it.
Finally, I'm using onScroll
on the ScrollView to update the state with the current y-value, thus making sure that the centre of the circle is always updated correctly!
Using onScroll
is a bit problematic if you want the exact scroll location as discussed on StackOverflow, but I'm happy with the results with onScroll
from react-native-circular-slider.
i noticed that in the setCircleCenter() function the py value was what wasnt being updated properly but that px was set correctly so i made py to be a function of px as shown in my below snippet.
For my use case this works, maybe you can find something similar.
A suggestion would be to find some way to call this.setCircleCenter(); after all rendering is complete, maybe onResponderGrant, but this would be a state change and cause rendering.
onLayout = () => {
this.setCircleCenter();
}
setCircleCenter() {
this._circle.measure((x, y, w, h, px , py) => {
const halfOfContainer = this.getContainerWidth() / 2;
this.setState({ circleCenterX: px + halfOfContainer, circleCenterY: px - (px/2.4) + halfOfContainer });
});
}
from react-native-circular-slider.
I found solution for my case too. I put circular slider in horizontal ScrollView, so px
was wrong value, just px
subtracts total previous items width, and it works fine 😁
from react-native-circular-slider.
I have figured out that the issue is caused by the sliders initial containerWidth being called asynchronously at the same time as the rendering of the SVG elements. the setState() on line 134 of circularSlider.js (inside the setCircleCenter() function) needs to complete before the component is mounted.
from react-native-circular-slider.
do you have any solutions?
from react-native-circular-slider.
Related Issues (20)
- Layout broken with RN 0.48 HOT 10
- Become a maintainer of this package HOT 6
- Tried to register two views with the same name RNSVGPath HOT 3
- How to Restrict BedTime Marker not to move beyond 0 ? Any Hack ?
- CircularSlider not slide on IOS HOT 16
- Some informations
- Undefined is not an object (evaluating '_react2.PropTypes.number') HOT 6
- how can i make this work on reactjs HOT 7
- ClockFace and circle is placed in wrong position HOT 3
- Component do not slide on Android
- I want the same for 33, 100 ,1000 instead of 360 .Do any one has any idea? HOT 1
- Ticks do not line up correctly with numbers HOT 1
- Cannot read property 'number' of undefined HOT 2
- How can I limit the travel range of an icon?
- Touch responsiveness of slider inaccurate after navigating to component using React Navigation HOT 1
- Suport for typescript HOT 4
- update needed
- Project status ?
- Unable to use in expo go HOT 2
- Cnnot read property 'number' of undefined in ClockFace HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-circular-slider.