I am trying to develop an app in React-Native, and I need to know that while you're swiping your finger in the screen and if you are on top of a component then to change color (basically just like we do with buttons on hover). onPress method does not work, since you may press out of it in the beginning then while you're swiping you might be on top of that (button), and only then I need to change the color of it.
So I need something like mouseeneter and mouseleave events on the web.
I also tried to add onStartShouldSetResponder, onMoveShouldSetResponder, onResponderMove, onResponderRelease referencing to: https://facebook.github.io/react-native/docs/gesture-responder-system , but that doesn't seem to work. That's because in style I'm working with position: absolute and its not working properly.
Related
In my app, I have horizontal FlatList which is used for swiping between several sub-pages of a screen. This works great.
However, on one of the pages, I have a Slider component. On iOS it works fine, but on Android, the parent ScrollView of the FlatList seems to "steal" the swipe gesture. I am only able to adjust the Slider by clicking very precisely on its thin line, but I cannot adjust it by sliding.
What I need is something like one of these
A view that wraps the Slider component and stops swipe gestures from being propagated to the parent ScrollView
A way to make the FlatList/ScrollView not consume swipes directly on elements that responds to horizontal swipes themself
Somehow adjust the area of which the Slider component will eat the touches around it (it's very small and hard to hit directly). I already tried adding a hitSlop prop, with no luck.
Any suggestions for a solution are very appreciated :)
Check example code and result here.
https://snack.expo.io/#esbenvb/mad-yogurt
I watched this presentation and there's a section on how to build an IOS Maps like UI. When dragging from the bottom to top, it drags to the top, and after it reaches the top, it continues scrolling up. Also, when scrolling down, when it reached the top content of the ScrollView, it continues to drag down.
It is suggested that it can be done using ScrollView by adding an empty transparent cell as the first element on the ScrollView. I have tried implementing the same which can be found in this snack. In my case, instead of Maps, I am using another ScrollView.
But the problem is that the first element (transparent element) does not allow to interact with the First ScrollView elements. I have tried with pointerEvents inside the first transparent view and even in its parent ScrollView. But this does not help. Has anyone tried implementing this kind of use case with react-native? All I found was this library, but I think it's not maintained properly.
you need to set the z-index of the transparent view to send it under/behind the interactive content, here is a good resource:
https://philipwalton.com/articles/what-no-one-told-you-about-z-index/
Edit: Actually I could not accomplish it, it seems like everything inside a scrollview will always be behind or in front of other elements, it seems like you can't have part of the scrollview behind something else and another part in front of something else.
I would like to create a carousel that scrolls automatically until the user scrolls / touches the ScrollView itself.
The auto-scrolling itself works fine with using scrollView.scrollTo but how could I detect if the user is interacting with the ScrollView? I took a look at the onScroll event but this does not seem to distinct between a user generated event and an event that was generated by calling scrollTo.
Also I'd like to know if it is possible to get the current scroll position from the ScrollView directly instead of reading it everytime from the onScroll event.
I'm very thankful for any tips and suggestions.
By digging into ScrollView's source code you can notice a few undocumented callbacks that will help you achieve what you're after, namely onTouchStart and onTouchEnd. These two callbacks are triggered only when user interacts with the ScrollView and not when you scroll programmatically.
You will probably want to clear your auto-scroll interval on onTouchStart and restart it after a delay on onTouchEnd.
Regarding your next question, the answer is no. As far as I know, no getter is currently exposed to retrieve the current scroll position. Therefore, you need to rely on the event passed to onScroll, retrieve event.nativeEvent.contentOffset['x' or 'y'], and store it in your component's state.
Note that if you're doing some heavy animations that need to follow scroll position closely (e.g. animated header or parallax image), it would be a good idea to use the native driver for Animated.event. You can learn more about it on React Native's blog.
I'm trying to create a simple animation example on the Windows Phone 8, but I imagine this should apply for WPF, WinRT, etc. anywhere XAML is used.
How do you animate the opacity of an to change from 0 to 1 when a 's click event is fired?
I've seen many examples of animations, but the button is always animating it's own properties, not the properties of a different control. I know I'm missing something small but I'm stumped -- no matter what I try I get XAML parse exceptions. I can get this to work with C#, but not with XAML.
Here is easy way to handle storyboard animation on any component and control by another component
http://msdn.microsoft.com/en-us/library/windows/apps/dn263220.aspx
I have a slider in windows phone as shown in figure. When I swipe the slider it's working. But what I want is, if I swipe the slider and leave it in the middle without reaching the end of the slider - it should return back to the beginning like elastic. If it was swiped to the end then it should navigate to the next page. Why I am using slider is, I need to control a text's opacity with animation. How to do this task?
I would use VisualStates to provide the animation, then you don't have to worry about the physics of it. I have created a similar scenario for a notification style Windows Phone effect, you know how you can swipe a notification off to the right. Basically it would be something like this:
OnManipulationStarted VisualStateManager.GoToState for OpenBegin or ClosedBegin depending on the state
OnManipulationDelta you can check e.Delta.X and if < 0 its moving left otherwise it's moving right or just check the position OnManipulationCompleted
After you know what the state call VisualStateManager.GoToState for OpenEnd or ClosedEnd and it will animate back to the specified location.
Add a comment if you need more help/code