@@ -50,14 +50,14 @@ const AffixProps = {
5050} ;
5151const Affix = defineComponent ( {
5252 name : 'AAffix' ,
53- props : AffixProps ,
5453 mixins : [ BaseMixin ] ,
54+ props : AffixProps ,
55+ emits : [ 'change' , 'testUpdatePosition' ] ,
5556 setup ( ) {
5657 return {
5758 configProvider : inject ( 'configProvider' , defaultConfigProvider ) ,
5859 } ;
5960 } ,
60- emits : [ 'change' , 'testUpdatePosition' ] ,
6161 data ( ) {
6262 return {
6363 affixStyle : undefined ,
@@ -68,25 +68,6 @@ const Affix = defineComponent({
6868 timeout : null ,
6969 } ;
7070 } ,
71- beforeMount ( ) {
72- this . updatePosition = throttleByAnimationFrame ( this . updatePosition ) ;
73- this . lazyUpdatePosition = throttleByAnimationFrame ( this . lazyUpdatePosition ) ;
74- } ,
75- mounted ( ) {
76- const { target } = this ;
77- if ( target ) {
78- // [Legacy] Wait for parent component ref has its value.
79- // We should use target as directly element instead of function which makes element check hard.
80- this . timeout = setTimeout ( ( ) => {
81- addObserveTarget ( target ( ) , this ) ;
82- // Mock Event object.
83- this . updatePosition ( ) ;
84- } ) ;
85- }
86- } ,
87- updated ( ) {
88- this . measure ( ) ;
89- } ,
9071 watch : {
9172 target ( val ) {
9273 let newTarget = null ;
@@ -110,6 +91,25 @@ const Affix = defineComponent({
11091 this . updatePosition ( ) ;
11192 } ,
11293 } ,
94+ beforeMount ( ) {
95+ this . updatePosition = throttleByAnimationFrame ( this . updatePosition ) ;
96+ this . lazyUpdatePosition = throttleByAnimationFrame ( this . lazyUpdatePosition ) ;
97+ } ,
98+ mounted ( ) {
99+ const { target } = this ;
100+ if ( target ) {
101+ // [Legacy] Wait for parent component ref has its value.
102+ // We should use target as directly element instead of function which makes element check hard.
103+ this . timeout = setTimeout ( ( ) => {
104+ addObserveTarget ( target ( ) , this ) ;
105+ // Mock Event object.
106+ this . updatePosition ( ) ;
107+ } ) ;
108+ }
109+ } ,
110+ updated ( ) {
111+ this . measure ( ) ;
112+ } ,
113113 beforeUnmount ( ) {
114114 clearTimeout ( this . timeout ) ;
115115 removeObserveTarget ( this ) ;
0 commit comments