File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
android/src/main/java/com/reactnativepagerview Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ class NestedScrollableHost : FrameLayout {
23
23
constructor (context: Context ) : super (context)
24
24
constructor (context: Context , attrs: AttributeSet ? ) : super (context, attrs)
25
25
public var initialIndex: Int? = null
26
+ public var didSetInitialIndex = false
26
27
private var touchSlop = 0
27
28
private var initialX = 0f
28
29
private var initialY = 0f
Original file line number Diff line number Diff line change @@ -96,6 +96,11 @@ class PagerViewViewManager : ViewGroupManager<NestedScrollableHost>() {
96
96
// https://github.com/facebook/react-native/issues/17968#issuecomment-697136929
97
97
refreshViewChildrenLayout(parent)
98
98
}
99
+
100
+ if (! host.didSetInitialIndex && host.initialIndex == index) {
101
+ host.didSetInitialIndex = true
102
+ setCurrentItem(parent, index, false )
103
+ }
99
104
}
100
105
101
106
override fun getChildCount (parent : NestedScrollableHost ) = getViewPager(parent).adapter?.itemCount ? : 0
@@ -148,9 +153,9 @@ class PagerViewViewManager : ViewGroupManager<NestedScrollableHost>() {
148
153
// https://github.com/callstack/react-native-pager-view/issues/456
149
154
// Initial index should be set only once.
150
155
if (host.initialIndex == = null ) {
156
+ host.initialIndex = value
151
157
view.post {
152
- setCurrentItem(view, value, false )
153
- host.initialIndex = value
158
+ host.didSetInitialIndex = true
154
159
}
155
160
}
156
161
}
You can’t perform that action at this time.
0 commit comments