Comments (7)
not sure if the state is saved if the user scrolls. State meaning the new appearance of the view that was mutated.
It's necessary to have some code for tracking the view mutations made outside of the scope of Components. Component Controllers is one way to do this.
I'm not sure what the exact problems you're referring to are, but this line will be the source of some problems:
frame.origin.x += [gesture translationInView:gesture.view.superview].x;
-translationInView:
doesn't provide a delta since the last gesture update, it's the total translation since the beginning of the pan gesture. Apple's docs say:
do not concatenate the value each time the handler is called.
If -didPan:gesture:
is moved to the component controller, then that controller can maintain the state being changed in the gesture (and any other non-Component state). The controller can also capture the starting point, and then, when the gesture handler is called with state == UIGestureRecognizerStateChanged
, the controller can update the x
based on the starting x
and the translation x
.
frame.origin.x = self.startingPoint.x + [gesture translationInView:gesture.view.superview].x;
Hope that helps.
EDIT: Oh, is the -setTranslation:
call there to make it so that the translation updates are actually deltas? I've never tried that technique. If it's not working here, does it work in a non-Components project?
from componentkit.
I had a bug-o .
I should have also set the translation to zero after setting the offset of the view.
I guess my question is more general.
As I am building component hierarchies as opposed to view hierarchies, I'm not sure which view should get the gesture attached to it.
And since the view is re-used, I don't know how the state should be saved.
Is there an example of using gestures I could reference against?
from componentkit.
The videos in the FB feed can be dragged around - I think its a pretty similar case
from componentkit.
I'm also interested in this.
from componentkit.
You want to keep around any necessary state in your controller (which will get the gesture actions via the responder chain). You can then apply any state to the view when it's mounted. This will preserve it across remounts, and you can re-apply to any new view that is mounted.
from componentkit.
Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.
from componentkit.
Did you try our suggestion? Going to close if there isn't anything concrete we can answer.
from componentkit.
Related Issues (20)
- Component not release
- [Documentation] Views path is not render HOT 3
- Delete 'Carthage/Checkouts' directory
- question - docs (docusaurus) repo? HOT 2
- Xcode not building ComponentKit checked out via cocoapods HOT 2
- Docusaurus source code
- question: My component is not getting full width in screen landscape mode. HOT 1
- Not Support Incremental mount
- Build Error with "RenderCoreLayoutCaching" HOT 1
- ComponentKit does not compile with Xcode 12.5 HOT 1
- Compile Error: Block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior HOT 1
- How do I pass multiple arguments
- Unsupported Swift Version: “FBSnapshotTestCase iOS” contains source code developed with Swift 3.x.
- [Question]How to unmount components from HostingView?
- How to make children component height equal to Scroll component's content view height but Scroll component's height HOT 2
- Yoga-internal.h:135:11: error: definition of implicit copy constructor for 'Values<9>' is deprecated
- CKNonNull.h:47:33 No member named 'move' in namespace 'std'; did you mean 'modf'?
- Abandoned?
- ComponentKit/ComponentKit.xcconfig is compiled as source code
- Unable to compile example project
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 componentkit.