Coder Social home page Coder Social logo

Comments (7)

kastiglione avatar kastiglione commented on April 24, 2024

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.

avnerbarr avatar avnerbarr commented on April 24, 2024

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.

avnerbarr avatar avnerbarr commented on April 24, 2024

The videos in the FB feed can be dragged around - I think its a pretty similar case

from componentkit.

mbrgm avatar mbrgm commented on April 24, 2024

I'm also interested in this.

from componentkit.

darknoon avatar darknoon commented on April 24, 2024

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.

 avatar commented on April 24, 2024

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.

darknoon avatar darknoon commented on April 24, 2024

Did you try our suggestion? Going to close if there isn't anything concrete we can answer.

from componentkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.