Horizontal Drag

4 minutes
Share the link to this page
Copied
  Completed
Horizontal drag onHorizontalDragStart A pointer has contacted the screen and might begin to move horizontally. onHorizontalDragUpdate A pointer that is in contact with the screen and moving horizontally has moved in the horizontal direction. onHorizontalDragEnd A pointer that was previously in contact with the screen and moving horizontally is no longer in contact with the screen and was moving at a specific velocity when it stopped contacting the screen.

Transcript

Hello, in this video we are going to look at the horizontal drag gesture. So the horizontal drag. Essentially if you drag your finger you know your point to wherever it is, in this case, it's going to be a mouse simulating the finger because it's time to simulate emulator. Whatever it is to drag it horizontally from left to right in as it should detect that gesture. Interesting. Open down.

That's the virtual drive. I've got a separate video covering that. go free. Check that right. So we've got this image right here. And what we want to do is detect when we're dragging left and right.

This could be useful if you have a carousel you could be swiping between Madrid to be sought in between posts, posts, between pages, not anything really. But I'm just going to get the detection done prints them in there and what you do with it and the way you do it is totally up to you. And what we want to do is create a child and this is gonna be gesture detector inside of this child. We are To put the you know the widget that we want to apply the gesture to, then we need to do on horizontal lifting different ones starts when you first click it update when you're scrolling. And you know, when lifted off, down is similar to start and avoid still on there cancel is when something interrupts your phone. Like if you get a phone call, essentially, the phone call comes to the, you know, the calling app, your phone now comes to the foreground and your app goes to the background and it's no longer you know, you know, taken away as it would be fueled using the free start.

And it's nice to have nice dragged start detailed. I was gonna say start with no grades. So if I click on it, as you can see If detected, and you'll get different coordinates, and this is relative to the screen before click off it, it doesn't do anything. It's only on the image itself. So if I click it and I drag, nothing happens, that's because we need it for copy and paste. We need the drag, update gesture, and we need to have the appropriate drug update details parameter and it needs to update well, because they go back to it.

And if I click on it, it says start and then for drug left, we get update. And obviously, we've got loads of different ones as exam dragon left and right now, so what are these values, so we're only we're only getting values even if we move up and down, right again, values I didn't see in the x axis because days horizontal drag, we get different values. So if we open it up again, I click, scroll to the bottom. So if I click And I scroll left, we get a minus value. And if I scroll right, we get a positive. And really, that's all there is to it using those values using No, sometimes they're called like the I think the Delta.

Using that value, you can determine not only what direction the scroll is, if it's positive, it's the same as same thing as a user swiping to the right. It's negative sampling of the the swipe to the left. But you can also detect if you look the speed of it, because obviously, we've got different values, which allows you to determine maybe how many items to scroll through and dissect one we used to do as an extra task is to add all of the other gestures for horizontal drive. So there's end down and cancel and actually simulate them get get them working. And finally, I want you to figure out how to get this individual x value from detail. You can do dot you can check out all of the other properties right there.

That's it. If you have any questions, feel free to pop me a message, and I do. I look forward to seeing you in the next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.