File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -8,27 +8,23 @@ import { ItemProps, SlotProps } from './props'
8
8
9
9
const Wrapper = {
10
10
created ( ) {
11
- this . hasInitial = false
12
11
this . shapeKey = this . horizontal ? 'offsetWidth' : 'offsetHeight'
13
12
} ,
14
13
15
14
mounted ( ) {
16
- // dispatch once at initial
17
- this . dispatchSizeChange ( )
18
-
19
15
if ( typeof ResizeObserver !== 'undefined' ) {
20
16
this . resizeObserver = new ResizeObserver ( ( ) => {
21
- // dispatch when size changed
22
- if ( this . hasInitial ) {
23
- this . dispatchSizeChange ( )
24
- } else {
25
- this . hasInitial = true
26
- }
17
+ this . dispatchSizeChange ( )
27
18
} )
28
19
this . resizeObserver . observe ( this . $el )
29
20
}
30
21
} ,
31
22
23
+ // since componet will be reused, so disptach when updated
24
+ updated ( ) {
25
+ this . dispatchSizeChange ( )
26
+ } ,
27
+
32
28
beforeDestroy ( ) {
33
29
if ( this . resizeObserver ) {
34
30
this . resizeObserver . disconnect ( )
You can’t perform that action at this time.
0 commit comments