ScrollPager icon indicating copy to clipboard operation
ScrollPager copied to clipboard

Problem with orientation change

Open smamczak opened this issue 7 years ago • 3 comments

Hi, I have 4 views with Labels. When I change orientation the view is in wrong position (I think the scroll view is responsible for this).

This is how it looks

and from landscape to portrait

I have managed to do some nasty hack with this code

var lastIndex = 0

func scrollPager(scrollPager: ScrollPager, changedIndex: Int) {
    print("scrollPager index changed: \(changedIndex)")
    lastIndex = changedIndex
}

override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) {
    coordinator.animate(alongsideTransition: nil) { _ in
            
        self.scrollPager.setSelectedIndex(index: self.lastIndex, animated: false)
    }
}

It would be much better when selectedIndex property was public (the getter) than private because I wouldn't have to remember the index. Please fix this to scroll automatically to right view when orientation changes.

smamczak avatar May 08 '17 12:05 smamczak

Thanks for reporting. does this happen on the demo project?

aryaxt avatar May 09 '17 03:05 aryaxt

@aryaxt yes

smamczak avatar May 09 '17 08:05 smamczak

@aryaxt Hi, I fixed this issue. Hoping you could review my PR #40.

cafedeichi avatar Aug 20 '20 00:08 cafedeichi