@@ -87,13 +87,22 @@ export class PickerColumn implements ComponentInterface {
87
87
* height of 0px.
88
88
*/
89
89
componentWillLoad ( ) {
90
+ /**
91
+ * We cache parentEl in a local variable
92
+ * so we don't need to keep accessing
93
+ * the class variable (which comes with
94
+ * a small performance hit)
95
+ */
96
+ const parentEl = ( this . parentEl = this . el . closest ( 'ion-picker' ) as HTMLIonPickerElement | null ) ;
97
+
90
98
const visibleCallback = ( entries : IntersectionObserverEntry [ ] ) => {
91
99
const ev = entries [ 0 ] ;
92
100
93
101
if ( ev . isIntersecting ) {
94
102
const { activeItem, el } = this ;
95
103
96
104
this . isColumnVisible = true ;
105
+
97
106
/**
98
107
* Because this initial call to scrollActiveItemIntoView has to fire before
99
108
* the scroll listener is set up, we need to manage the active class manually.
@@ -119,9 +128,17 @@ export class PickerColumn implements ComponentInterface {
119
128
}
120
129
}
121
130
} ;
122
- new IntersectionObserver ( visibleCallback , { threshold : 0.001 } ) . observe ( this . el ) ;
131
+ /**
132
+ * Set the root to be the parent picker element
133
+ * This causes the IO callback
134
+ * to be fired in WebKit as soon as the element
135
+ * is visible. If we used the default root value
136
+ * then WebKit would only fire the IO callback
137
+ * after any animations (such as a modal transition)
138
+ * finished, and there would potentially be a flicker.
139
+ */
140
+ new IntersectionObserver ( visibleCallback , { threshold : 0.001 , root : this . parentEl } ) . observe ( this . el ) ;
123
141
124
- const parentEl = ( this . parentEl = this . el . closest ( 'ion-picker' ) as HTMLIonPickerElement | null ) ;
125
142
if ( parentEl !== null ) {
126
143
// TODO(FW-2832): type
127
144
parentEl . addEventListener ( 'ionInputModeChange' , ( ev : any ) => this . inputModeChange ( ev ) ) ;
0 commit comments