React native - onPressIn cancel on scrolling - reactjs

I want to invoke function imediatly when user touch the TouchableWithoutFeedback, but if i use OnPressIn i have problem with scrolling. When user scroll - he activate the function. OnPress event on other hand is slow. What i need use? I want when user touch TouchableOpacity view to fire the function without need of release the button. OnPressIn with proper scroll functionality.
The items are inside FlatList. Every item need to have onPressIn and to be able to scroll without trigger onPressIn.

Related

Continously Calling function while holding a react native touchable component

I want to simulate the progressive bar that is on Snapchat story when recording a story. Everything is done but the button touch effect. How do you call a function while holding the button, not just onPress?
If you are using one of the Touchable buttons, I would use a combination of the onPressIn and onPressOut props to perform an operation while the user is holding the button. See more info here

Is there a way to prevent a side panel in React from re-rendering (scrolling back to the top of the panel) when I click a button on the panel?

In a React app, I have a side panel with multiple accordions, enough that users have to scroll down to see them all. When I click on a button lower on the panel, the panel appears to re-render (refreshes and looks as if user had scrolled back to the top of the panel). Is there a way to prevent this re-render so that when a user clicks a button, the panel doesn't move/scroll/re-render (so that the button and accordion that the user was viewing are still visible)?
I expect the panel to not re-render or scroll back to the top when a user clicks a button on the lower part of the panel.
I was able to resolve this: it all was related to setState() forcing the sidebar to re-render due to how I handled the keys related to the buttons/tabs in the sidebar. Since I reset the keys each time a button/tab was clicked, the sidebar re-rendered regardless of the event.preventDefault() I added. Once I removed the function that reset the keys each time I changed state by clicking a button/tab, the sidebar stopped re-rendering.

Make onMomentumScrollEnd listen to only touch interactions - not scrollTo method

I have a ScrollView and I am using the onMomentumScrollEnd event to trigger a function but I also have a button that uses the scrollTo method which then also fires the function from the onMomentumScrollEnd event. Is there way to trigger the onMomentumScrollEnd event only when it is from a touch interaction?
I have tried to use onScrollEndDrag instead since it is specific to touch interactions, but I specifically need the position of the ScrollView when it glides to a stop

Drag finger from one button to another - want to un-trigger old button and trigger new button - Windows Store

I am working on a windows store application and I want to be able to drag between buttons so that the originally pressed button becomes deactivated and the newly "dragged onto" button becomes activated but I can't seem to get this to work.
I have 2 Buttons inside a StackPanel and the events I have on them are:
PointerPressed
PointerEntered
PointerReleased
PointerExited
PointerCanceled
PointerCaptureLost
PointerPressed and PointerEntered share the same event handler and the rest (the "deactivation" events) share the same event handler.
If I press one button my "activated" event handler is triggered and if I drag off it my "deactivated" event handler is triggered but if I then drag onto the second button the "activated" event handler isn't triggered again.
Strangely, if I start by dragging from off the StackPanel onto one of the buttons the "activated" event handler is triggered. I assume that it is something to do with the internal pointer management stuff but can't seem to find a workaround.
Does anyone know why this is happening and how I can get it to work how I want?
Thanks for your time.
Edit
Okay I've been researching some stuff and I've come across CapturePointer() and ReleasePointerCapture() but this seems to be broken - If I capture the pointer, when I take my finger off the screen, PointerReleased doesn't even get hit.
I've also realized why the "dragging from off the SP onto one of the buttons causes it to 'activate'" - this is because when a button is pressed it doesn't route its event but fires a Click event - meaning the same pointer cannot fire a PointerEntered event of another button, but if it starts outside a Button it will trigger PointerEntered.
This doesn't get me much further but it is a little extra info :)
The concept of Button is a bit unique in regard to mouse capture and how dragging away from it happens. In your scenario I'm not sure if the event model around Button will work correctly for you. On Button, when a pointer is depressed (mouse) it has capture until it is released. This is not the same for touch where a press and drag away is different because in touch there isn't any explicit capture unless you create it.
So what you are hitting is going to be a slight conflict between mouse/touch interactions anyway using Button -- using some other UI element (not sure if you have a styled button) should get you what you want.

Silverlight click event registered a second time before first event completed

I have a button which launches a "modal dialog" - it just creates a transparent grid covering everything, with the "dialog" created on top of that.
However I have a strange issue - if I double/triple click the button really fast (or add some delay in the event code), the button click event is executed multiple times, creating multiple overlapping modal dialogs. If the first action in my event is to disable the button (IsEnabled=false) it seems to prevent this.
My guess is that Silverlight is being multithreaded with input - it is not only recording the second click in another thread (while the button's click event is running), but it is jumping the gun by evaluating which control should be the target before the previous event has finished executing. Even though that event alters what control is at those mouse coordinates, it doesn't matter.
Does anyone know anything about this behavoir, or a way around it? If I have something like a save window, where the user clicks a save button, a blocking grid ("Saving...") is placed up while it saves, and then the whole "window" is closed, I'd like to avoid the user being able to queue up multiple save event clicks (this could lead to unpredictable program behavoir).
If you've ever worked with WinForms or WPF, this is expected behavior. Your button is broadcasting its Click event until your modal dialog covers it up. Unfortunately, there is some amount of time between your first click and when the modal dialog covers the button which allows multiple clicks to the original button.
You have two solution choices:
Disable the button after the first click and then re-enable after the modal dialog returns. You've already mentioned that this works.
Write code in the Event Handler of the button to determine if a modal dialog is already being displayed. This way, you're putting the responsibility in one location rather than splitting it up (disabling and re-enabling the button). This would be my preferred solution.
I think what you're seeing is the behaviour of Silverlight's routed events.
You can set the Handled property of the event arguments to true to prevent the event from bubbling.

Resources