SwiftKickMobile / TLLayoutTransitioning

Enhanced transitioning between UICollectionView layouts in iOS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disable bounce effect in interactive transitions

jakunico opened this issue · comments

Hi!

There seems to be a bounce effect when you complete an interactive transition, I'd like to replace that by just decelerating to final position without bouncing.

You can check this effect in the Example project, if you pinch and release it'll complete the interactive transition with a bounce effect going a bit further than final progress in some cases.

The workaround I found is to subclass TLTransitionLayout and override the setProgress:time: method limiting values to 0..1

- (void)setTransitionProgress:(CGFloat)transitionProgress time:(CGFloat)time
{
    [super setTransitionProgress:MAX(0, MIN(transitionProgress, 1.f)) time:MAX(0, MIN(time, 1.f))];
}

This does get rid for the bounce effect (it's no longer visible to the user) but the transition still takes some time to complete because it thinks it's bouncing.

Any idea how can I solve this issue?

Thanks in advance,

Nicolás.

The underlying problem with this is that this bounce comes from UIKit. What I mean is, when you finish or cancel the transition, UIKit drives the progress to completion and bounces the value beyond [0, 1] as it sees fit (as far as I can tell from experimentation). To eliminate the bounce cleanly, we would need to know the bounce formula in order to counteract it.

So I don't have a better idea than what you're already doing.

You might be interested in looking at #25, which talks about discrete jumps at the end of the transition. The underlying cause is that TLLayoutTransitioning truncates progress between [0, 1] like you've done above in some calculations but not others. I'm in the process of removing all of this truncation to resolve #25, but I don't think this will affect your workaround.

I see. I spent some hours looking for a workaround without success. It's a minor issue in our app so we're just going to focus on other stuff for now. Will update if I get to work on this again.

Thanks !

@wtmoose Have you found a solution?

@AEugene no, I have not.