File tree 1 file changed +12
-4
lines changed
android/src/main/java/com/reactnativepagerview
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 1
1
package com.reactnativepagerview
2
2
3
3
import android.view.View
4
+ import android.view.ViewGroup
4
5
import androidx.viewpager2.widget.ViewPager2
5
6
import com.facebook.react.uimanager.PixelUtil
6
7
@@ -69,12 +70,19 @@ object PagerViewViewManagerImpl {
69
70
fun removeViewAt (parent : NestedScrollableHost , index : Int ) {
70
71
val pager = getViewPager(parent)
71
72
val adapter = pager.adapter as ViewPagerAdapter ?
73
+
74
+ val child = adapter?.getChildAt(index)
75
+
76
+ if (child != null && child.parent != null ) {
77
+ (child.parent as ? ViewGroup )?.removeView(child)
78
+ }
79
+
72
80
adapter?.removeChildAt(index)
73
81
74
- // Required so ViewPager actually animates the removed view right away (otherwise
75
- // a white screen is shown until the next user interaction).
76
- // https://github.com/facebook/react-native/issues/17968#issuecomment-697136929
77
- refreshViewChildrenLayout(pager)
82
+ pager.post {
83
+ pager.invalidate()
84
+ pager.requestLayout()
85
+ }
78
86
}
79
87
80
88
fun needsCustomLayoutForChildren (): Boolean {
You can’t perform that action at this time.
0 commit comments