honcheng / PaperFold-for-iOS

Paper folding animation for iOS
Other
2.7k stars 399 forks source link

"Jump" when closing top fold and opening bottom fold #35

Open funkyboy opened 11 years ago

funkyboy commented 11 years ago
  1. Download the current master and run the project PaperFold.xcodeproj.
  2. Slide down to open the top fold.
  3. Then slide up very slowly.
  4. You will notice that, as soon as you get to close the top fold the bottom fold is completely open.

The same happens when you slowly close the bottom fold.

I'd like to help. Can you point me into the right direction?

honcheng commented 11 years ago

I suspect it has to do with the state. Maybe the moment the bottom fold opens, it uses the last displacement distance if your gesture, instead of resetting to 0

funkyboy commented 11 years ago

In

- (void)animateWithContentOffset:(CGPoint)point panned:(BOOL)panned

I have added a return statement when y is 0 and this solved my issue

  else if (self.paperFoldInitialPanDirection==PaperFoldInitialPanDirectionVertical) {

        float y = point.y;
        if (self.state!=self.lastState) self.lastState = self.state;

        if(y == 0)
            return;

This solved my issue

honcheng commented 11 years ago

Thanks. Really appreciate this. I'll try to incorporate this solution, after I test that it doesn't affect anything else.

On 6 Dec, 2012, at 6:08 PM, Cesare notifications@github.com wrote:

In

  • (void)animateWithContentOffset:(CGPoint)point panned:(BOOL)panned

I have added a return statement when y is 0 and this solved my issue

else if (self.paperFoldInitialPanDirection==PaperFoldInitialPanDirectionVertical) {

    float y = point.y;
    if (self.state!=self.lastState) self.lastState = self.state;

    if(y == 0)
        return;

This solved my issue

— Reply to this email directly or view it on GitHub.