You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to figure out how to customize the "scaleAndRotate" example to also allow for panning/dragging the image simultaniously while doing the other two gestures (or by itself, of course), but I can't quite figure it out. I think it'd be great with an example for that, as I'm trying to build the ubiquitous "sticker-on-photo" UX (a la Snapchat/Messenger or Instagram stories), and thought this library would be a great solution, and which I think many other developers will want to/have to implement :-)
If you give me a pointer or a code snippet, I could perhaps make a working example and a PR with it.
The Animated.View around the image seemed redundant, though, so I tried removing it and moving the translation transform to the image itself. It's functional, but I get these weird drawing errors on pan gestures:
Hey @jhalborg! Glad to see how far have you managed to get with your demo app. Nice progress!
I'm just trying to understand what this issue is about and my understanding is that you managed to get around most of the gesture handler related issues. So my understanding is that you wanted to know why are you getting these visual artifacts while panning when you use Animated.Image as direct child instead of wrapping it in an Animated.View? If so then to be honest I don't know why this could be happening and would like to know if this is somehow related to gesture handler library. Would you be able to try to start an animation for translateX/translateY value instead of panning to see if this could be caused by gesture handler or maybe just related to animating transform property?
Sure, let me clarify 😄 . I managed to get pinch-to-zoom as well as rotate-with-two-fingers to work simultaneously, but the user can't drag/pan the image while doing the other two. The apps I mentioned (Snapchat, Messenger stories) exemplify how I think the UX should be - if the user touches the image with two fingers, he/she should be able to mutate the image on all params simultaneously (pan, zoom, rotate).
Made it work with all three gesture handlers - should have read the docs more carefully, as it clearly says that I can use an array for simultaneousHandlers
I've posted a snack here of the sticker. It's still a WIP, as I still need to figure out how to handle the rendering issue mentioned above, as well as use the native driver.
Great work @jhalborg ! Happy you managed to get it to work. Have you managed to validate if the rendering issue is related to gesture handler or maybe it is some problem with using transforms in react native (I suggested that you start timing Animation on one of these properties instead of connecting it to handler). If that is the case can you please close this issue?
@jhalborg can you share what simulator/device/iOS version are you seeing this on? I'm quite confident this visual issue isn't related to gesture handler library but you never know...
@zachgibson@kmagiera - Thanks for investigating, and sorry for being so late with the response. I've finally been allotted some more time to doing the sticker-thing, so I'm back on issue now :-)
I can't reproduce the tearing anymore, so it must have been some environment anomaly.
I think I now have something that's a passable experience for the user, except for two remaining issues
Initial placement
I've tried modifying the initial placement of the sticker component on the screen by setting the following in the constructor:
This works fine on first draw, but the sticker jumps on first drag. On subsequent drags, everything is fine, and it jumps back to the 'expected' position after first release. I can't seem to find a solution to this, maybe one of you can help?
Using native driver
@kmagiera, you mentioned in another issue that in order to use native driver on nested gesture handlers, I should just add an Animated.View between each handler. I can't get this to work, it seems. In my current code, the sticker component simply disappears. Do you have a working example somewhere?
I've created a snack here, but perhaps it's more of a gist seeing as Snack seems to have problems importing this very lib at the moment.
I'd love some feedback/help :-)
EDIT: In relation to the first issue, suggestions on how to implement a "Reset position" button would also be welcome - It doesn't seem that a simple setValue works for me.
I'm wondering about this in the code: if (event.nativeEvent.oldState === State.ACTIVE)
Wouldn't event.nativeEvent.oldState would be undefined as it's not being declared?
@jhalborg
Hi, I'm a little late, but I was wondering if there's a way to solve the pinch, in this case, when I try to enlarge the sticker more, it goes back to its original size and then it starts to expand
(My english is in work progress)
Activity
jhalborg commentedon Dec 12, 2017
So I'm slowly getting somewhere:
https://gyazo.com/97ef4f578b95a7c1242e4a3710a4e6da
The above result is with the following (typescript) code, most of it copy+pasted from the "draggable" and "scaleAndRotate" examples:
The Animated.View around the image seemed redundant, though, so I tried removing it and moving the translation transform to the image itself. It's functional, but I get these weird drawing errors on pan gestures:
https://gyazo.com/c4c66bd6bcd8f034b181ff68ac895fcf
The changed code:
Any idea as to why?
kmagiera commentedon Dec 13, 2017
Hey @jhalborg! Glad to see how far have you managed to get with your demo app. Nice progress!
I'm just trying to understand what this issue is about and my understanding is that you managed to get around most of the gesture handler related issues. So my understanding is that you wanted to know why are you getting these visual artifacts while panning when you use Animated.Image as direct child instead of wrapping it in an Animated.View? If so then to be honest I don't know why this could be happening and would like to know if this is somehow related to gesture handler library. Would you be able to try to start an animation for translateX/translateY value instead of panning to see if this could be caused by gesture handler or maybe just related to animating transform property?
jhalborg commentedon Dec 13, 2017
Sure, let me clarify 😄 . I managed to get pinch-to-zoom as well as rotate-with-two-fingers to work simultaneously, but the user can't drag/pan the image while doing the other two. The apps I mentioned (Snapchat, Messenger stories) exemplify how I think the UX should be - if the user touches the image with two fingers, he/she should be able to mutate the image on all params simultaneously (pan, zoom, rotate).
I've made a snack of the rendering issue here
jhalborg commentedon Dec 14, 2017
Made it work with all three gesture handlers - should have read the docs more carefully, as it clearly says that I can use an array for
simultaneousHandlersI've posted a snack here of the sticker. It's still a WIP, as I still need to figure out how to handle the rendering issue mentioned above, as well as use the native driver.
Any feedback/input is much appreciated
https://snack.expo.io/@jhalborg/sticker-example
kmagiera commentedon Dec 15, 2017
Great work @jhalborg ! Happy you managed to get it to work. Have you managed to validate if the rendering issue is related to gesture handler or maybe it is some problem with using transforms in react native (I suggested that you start timing Animation on one of these properties instead of connecting it to handler). If that is the case can you please close this issue?
zachgibson commentedon Dec 15, 2017
@jhalborg Just tried your snack on an iPhone 7+ 11.1.2 and it seems to work perfectly. No rendering issues at all. Are you testing on an Android?
kmagiera commentedon Dec 18, 2017
Thanks @zachgibson for trying this out.
@jhalborg can you share what simulator/device/iOS version are you seeing this on? I'm quite confident this visual issue isn't related to gesture handler library but you never know...
zachgibson commentedon Dec 18, 2017
@kmagiera No problem man. I’m really excited about react-native-gesture-handler so I want to try and help out any way I can.
kmagiera commentedon Jan 15, 2018
Closing this for now @jhalborg
If you happen to have some time to revisit and give us an update feel free to reopen
jhalborg commentedon Mar 19, 2018
@zachgibson @kmagiera - Thanks for investigating, and sorry for being so late with the response. I've finally been allotted some more time to doing the sticker-thing, so I'm back on issue now :-)
I can't reproduce the tearing anymore, so it must have been some environment anomaly.
I think I now have something that's a passable experience for the user, except for two remaining issues
Initial placement
I've tried modifying the initial placement of the sticker component on the screen by setting the following in the constructor:
This works fine on first draw, but the sticker jumps on first drag. On subsequent drags, everything is fine, and it jumps back to the 'expected' position after first release. I can't seem to find a solution to this, maybe one of you can help?
Using native driver
@kmagiera, you mentioned in another issue that in order to use native driver on nested gesture handlers, I should just add an
Animated.Viewbetween each handler. I can't get this to work, it seems. In my current code, the sticker component simply disappears. Do you have a working example somewhere?I've created a snack here, but perhaps it's more of a gist seeing as Snack seems to have problems importing this very lib at the moment.
I'd love some feedback/help :-)
EDIT: In relation to the first issue, suggestions on how to implement a "Reset position" button would also be welcome - It doesn't seem that a simple
setValueworks for me.jhalborg commentedon Mar 20, 2018
So, I figured out a fix for initial placement, but using a different approach - JSX instead of animated coords.
Before, I had:
But placement can instead be done by using the
ImageBackgroundcomponent:This does not solve the reset button use case, though
impactcolor commentedon Dec 3, 2019
I'm wondering about this in the code:
if (event.nativeEvent.oldState === State.ACTIVE)Wouldn't
event.nativeEvent.oldStatewould be undefined as it's not being declared?leo0grau commentedon Jul 16, 2021
@jhalborg
Hi, I'm a little late, but I was wondering if there's a way to solve the pinch, in this case, when I try to enlarge the sticker more, it goes back to its original size and then it starts to expand
(My english is in work progress)
[iOS] Fix callback crashes from detached gesture recognizers (#4679)
[iOS] Fix callback crashes from detached gesture recognizers (#4679)