evgenyneu / Auk

An image slideshow for iOS written in Swift.
MIT License
277 stars 44 forks source link

Slider stopping in the middle of the image #55

Open renanstig opened 7 years ago

renanstig commented 7 years ago

Hello,

I've been facing a strange issue, when the user move to other viewController in the middle of a scroll when you come back to the previous screen the slider remains static for awhile showing the image wrongly.

I solved this issue by adding a scrollToNextPage() in viewWillAppear function, but I'm wondering if there's a better solution for this issue.

I attached an image in case I wasn't clear enough simulator screen shot 11 jan 2017 13 30 44

Best regards, Renan.

evgenyneu commented 7 years ago

Hi @renanstig, thank you for reporting the issue and suggesting a solution.

I did not realize that it could happen. He is my hypothesis on why it happens. Auk's autoscrolling calls scrollView.setContentOffset(offset, animated: animated) to show the next page with animation. If you happen to be in the transition to a child view controller the scrolling stops when the parent view controller becomes invisible. It looks like the parent view controller is still in memory but it is frozen. When you click "Back" button, the parent view controller is shown again but the scrolling is not resumed from where it stopped. Hence, we see the scroll view animation in the incomplete state, stuck in the middle.

I think your solution is pretty simple, I don't have an alternative that takes less code to write. Please let me know if you find one.

SlonGL commented 5 years ago

When you change the scrollView.frame, the picture can also hang between the neighbours and the current picture independently and unexpectedly can become one of the neighbouring ones or remain current depending on the size of the frame