fermoya / SwiftUIPager

Native Pager in SwiftUI
MIT License
1.3k stars 172 forks source link

[BUG]Animation speed is too fast in iOS14.4+ #207

Closed conversun closed 3 years ago

conversun commented 3 years ago

https://user-images.githubusercontent.com/22893221/112798364-61351280-909f-11eb-8016-b59c472a3a2c.mov

fermoya commented 3 years ago

Hi @conversun , there's a template for this kind of issues. The description doesn't offer enough information.

I've just run the Sample project and the animation seems fine:

https://user-images.githubusercontent.com/11335612/112805203-3336da80-906d-11eb-8307-b5e1a7df2762.mov

This is customisable via pagingAnimation(_:). The default animation is easeOut(duration: 0.35)

conversun commented 3 years ago

@fermoya Sorry, I forgot to add device information

iPhone 12Pro 14.4.1 (14.4.0 Same exists)

This problem only occurs on real devices

fermoya commented 3 years ago

@conversun @beeirl could you please try version 2.0.0 and lmk if the issue is reproducible in this version?

beeirl commented 3 years ago

@fermoya 2.0.0 looks definitely way better. The animations are working. But if I use a custom animation and swipe faster it falls back to the default ease animation. So I guess the problem is still there it just occurs in a different shape.

fermoya commented 3 years ago

@beeirl I think I have a possible solution for this. I think PagerContent:224 should have the same animation as PagerContent:284. When the swipe is too fast, SwiftUI seems to ignore the last animation

beeirl commented 3 years ago

@fermoya oh yeah 100%

fermoya commented 3 years ago

does that mean that you tried it @beeirl ?

beeirl commented 3 years ago

@fermoya no I have not tested it but I have read through the code and in my opinion the current implementation reflects exactly the behavior I am experiencing.

fermoya commented 3 years ago

@beeirl I just created this branch with a possible solution in case you want to point at it: https://github.com/fermoya/SwiftUIPager/tree/feat/dragging-animation

beeirl commented 3 years ago

@fermoya It works like a charm. Thank you so much for taking care of that. Much appreciated.

conversun commented 3 years ago

@fermoya It works. Thank you

beeirl commented 3 years ago

@fermoya I just stumbled over a bug - if you swipe and hold the animation starts going crazy. Seems like something is off with the drag change

fermoya commented 3 years ago

@beeirl can you please show me a video?

beeirl commented 3 years ago

bet! It happens if you swipe and hold.

EDIT: this is how my draggingAnimation looks like:

.draggingAnimation(.custom(animation: .spring(response: 0.3, dampingFraction: 0.8, blendDuration: 1)))

https://user-images.githubusercontent.com/9655723/113117581-e1c65100-920e-11eb-9146-abf80dec6ed3.MP4

fermoya commented 3 years ago

@beeirl have you tried any other custom animation? Like an interactiveSpring? I don't think you're supposed to use spring in these scenario

fermoya commented 3 years ago

@beeirl I think you need a different animation or a lower response. With interactiveSpring that by default has a response of 0.15 you get a nice effect. Any other animation seems to be fine.

fermoya commented 3 years ago

Ive released version 2.2.0 with a new modifier onDraggingAnination(onChanged:,onEnded:). It's up to the user to choose one or another animation according to their needs. I've also added some notes about the issues here found. For now it's the best that can be done.