@@ -109,31 +109,48 @@ const Affix = defineComponent({
109109 const newState = {
110110 status : AffixStatus . None ,
111111 } as AffixState ;
112- const targetRect = getTargetRect ( targetNode ) ;
113112 const placeholderRect = getTargetRect ( placeholderNode . value as HTMLElement ) ;
113+
114+ if (
115+ placeholderRect . top === 0 &&
116+ placeholderRect . left === 0 &&
117+ placeholderRect . width === 0 &&
118+ placeholderRect . height === 0
119+ ) {
120+ return ;
121+ }
122+
123+ const targetRect = getTargetRect ( targetNode ) ;
114124 const fixedTop = getFixedTop ( placeholderRect , targetRect , offsetTop . value ) ;
115125 const fixedBottom = getFixedBottom ( placeholderRect , targetRect , offsetBottom . value ) ;
126+
116127 if ( fixedTop !== undefined ) {
128+ const width = `${ placeholderRect . width } px` ;
129+ const height = `${ placeholderRect . height } px` ;
130+
117131 newState . affixStyle = {
118132 position : 'fixed' ,
119133 top : fixedTop ,
120- width : placeholderRect . width + 'px' ,
121- height : placeholderRect . height + 'px' ,
134+ width,
135+ height,
122136 } ;
123137 newState . placeholderStyle = {
124- width : placeholderRect . width + 'px' ,
125- height : placeholderRect . height + 'px' ,
138+ width,
139+ height,
126140 } ;
127141 } else if ( fixedBottom !== undefined ) {
142+ const width = `${ placeholderRect . width } px` ;
143+ const height = `${ placeholderRect . height } px` ;
144+
128145 newState . affixStyle = {
129146 position : 'fixed' ,
130147 bottom : fixedBottom ,
131- width : placeholderRect . width + 'px' ,
132- height : placeholderRect . height + 'px' ,
148+ width,
149+ height,
133150 } ;
134151 newState . placeholderStyle = {
135- width : placeholderRect . width + 'px' ,
136- height : placeholderRect . height + 'px' ,
152+ width,
153+ height,
137154 } ;
138155 }
139156
0 commit comments