ZLSwipeableViewSwift icon indicating copy to clipboard operation
ZLSwipeableViewSwift copied to clipboard

animateView is called extra times

Open denirorobert opened this issue 7 years ago • 2 comments

Closure swipeableView.animateView is called multiple times. In my case with numberOfActiveView equal to 2 swipeableView.animateView is called 3 times for 1st view and 3 times for 2 view. This is incorrect, the correct behaviour should be 1 time per view.

As I found in your code it happens because of this:

open var nextView: NextViewHandler? {
        didSet {
            loadViews()
        }
    }
open func loadViews() {
      for _ in UInt(activeViews().count) ..< numberOfActiveView {
          if let nextView = nextView?() {
              insert(nextView, atIndex: 0)
          }
      }
      updateViews()
  }

actually as I understand these lines are the root cause (they create a loop and updateViews() method is called 3 times instead of 1): if let nextView = nextView?() { didSet { loadViews() }

denirorobert avatar Nov 07 '17 23:11 denirorobert

Thank you for investigating 🙃

I'd be more than happy to accept a Pull Request that fixes the behavior!

AndrewSB avatar Mar 12 '18 17:03 AndrewSB

@denirorobert @AndrewSB Hello. Did you found the solution of this problem?

abhi-dave avatar Dec 20 '18 14:12 abhi-dave