@@ -15,8 +15,8 @@ export const getRefresherAnimationType = (contentEl: HTMLIonContentElement): Ref
1515 return hasHeader ? 'translate' : 'scale' ;
1616} ;
1717
18- export const createPullingAnimation = ( type : RefresherAnimationType , pullingSpinner : HTMLElement ) => {
19- return type === 'scale' ? createScaleAnimation ( pullingSpinner ) : createTranslateAnimation ( pullingSpinner ) ;
18+ export const createPullingAnimation = ( type : RefresherAnimationType , pullingSpinner : HTMLElement , refresherEl : HTMLElement ) => {
19+ return type === 'scale' ? createScaleAnimation ( pullingSpinner , refresherEl ) : createTranslateAnimation ( pullingSpinner , refresherEl ) ;
2020} ;
2121
2222const createBaseAnimation = ( pullingRefresherIcon : HTMLElement ) => {
@@ -85,24 +85,42 @@ const createBaseAnimation = (pullingRefresherIcon: HTMLElement) => {
8585 return baseAnimation . addAnimation ( [ spinnerArrowContainerAnimation , circleInnerAnimation , circleOuterAnimation ] ) ;
8686} ;
8787
88- const createScaleAnimation = ( pullingRefresherIcon : HTMLElement ) => {
89- const height = pullingRefresherIcon . clientHeight ;
88+ const createScaleAnimation = ( pullingRefresherIcon : HTMLElement , refresherEl : HTMLElement ) => {
89+ /**
90+ * Do not take the height of the refresher icon
91+ * because at this point the DOM has not updated,
92+ * so the refresher icon is still hidden with
93+ * display: none.
94+ * The `ion-refresher` container height
95+ * is roughly the amount we need to offset
96+ * the icon by when pulling down.
97+ */
98+ const height = refresherEl . clientHeight ;
9099 const spinnerAnimation = createAnimation ( )
91100 . addElement ( pullingRefresherIcon )
92101 . keyframes ( [
93- { offset : 0 , transform : `scale(0) translateY(-${ height + 20 } px)` } ,
102+ { offset : 0 , transform : `scale(0) translateY(-${ height } px)` } ,
94103 { offset : 1 , transform : 'scale(1) translateY(100px)' }
95104 ] ) ;
96105
97106 return createBaseAnimation ( pullingRefresherIcon ) . addAnimation ( [ spinnerAnimation ] ) ;
98107} ;
99108
100- const createTranslateAnimation = ( pullingRefresherIcon : HTMLElement ) => {
101- const height = pullingRefresherIcon . clientHeight ;
109+ const createTranslateAnimation = ( pullingRefresherIcon : HTMLElement , refresherEl : HTMLElement ) => {
110+ /**
111+ * Do not take the height of the refresher icon
112+ * because at this point the DOM has not updated,
113+ * so the refresher icon is still hidden with
114+ * display: none.
115+ * The `ion-refresher` container height
116+ * is roughly the amount we need to offset
117+ * the icon by when pulling down.
118+ */
119+ const height = refresherEl . clientHeight ;
102120 const spinnerAnimation = createAnimation ( )
103121 . addElement ( pullingRefresherIcon )
104122 . keyframes ( [
105- { offset : 0 , transform : `translateY(-${ height + 20 } px)` } ,
123+ { offset : 0 , transform : `translateY(-${ height } px)` } ,
106124 { offset : 1 , transform : 'translateY(100px)' }
107125 ] ) ;
108126
0 commit comments