Skip to content

Commit b6a1d77

Browse files
authored
Merge pull request #33 from nativescript-community/ios-fix-custom-transformers-with-selectedIndex-change
fix[ios]: change selectedIndex with transformer break design
2 parents e667508 + 3e70b24 commit b6a1d77

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/ui-pager/index.ios.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,9 @@ export class Pager extends PagerBase {
380380
}
381381
// dispatch_async(main_queue, () => {
382382
if (this.mDataSource.collectionViewNumberOfItemsInSection(this.nativeViewProtected, 0) > maxMinIndex) {
383+
// when we have custom layouts (they don't occupy 100% of the parent) and we use custom transformers we need to call setContentOffsetAnimated to take size into account.
384+
// Reference: https://stackoverflow.com/a/53798708/6015400
385+
this.nativeViewProtected.setContentOffsetAnimated(CGPointMake(1, 0), !!animate);
383386
this.nativeViewProtected.scrollToItemAtIndexPathAtScrollPositionAnimated(
384387
NSIndexPath.indexPathForItemInSection(maxMinIndex, 0),
385388
this.orientation === 'vertical' ? UICollectionViewScrollPosition.CenteredVertically : UICollectionViewScrollPosition.CenteredHorizontally,

0 commit comments

Comments
 (0)