File tree 4 files changed +36
-8
lines changed
4 files changed +36
-8
lines changed Original file line number Diff line number Diff line change 70
70
"@fortawesome/vue-fontawesome" : " ^0.1.10" ,
71
71
"@types/jest" : " ^26.0.14" ,
72
72
"@types/node" : " ^14.11.10" ,
73
+ "@types/resize-observer-browser" : " ^0.1.7" ,
73
74
"@vue/test-utils" : " 1.0.0-beta.29" ,
74
75
"autoprefixer" : " ^9.6.1" ,
75
76
"babel-loader" : " ^8.0.6" ,
Original file line number Diff line number Diff line change @@ -138,7 +138,6 @@ export const BaseSlideGroup = mixins<options &
138
138
} ,
139
139
140
140
data : ( ) => ( {
141
- internalItemsLength : 0 ,
142
141
isOverflowing : false ,
143
142
resizeTimeout : 0 ,
144
143
startX : 0 ,
@@ -231,13 +230,26 @@ export const BaseSlideGroup = mixins<options &
231
230
} ,
232
231
} ,
233
232
234
- beforeUpdate ( ) {
235
- this . internalItemsLength = ( this . $children || [ ] ) . length
236
- } ,
237
-
238
- updated ( ) {
239
- if ( this . internalItemsLength === ( this . $children || [ ] ) . length ) return
240
- this . setWidths ( )
233
+ mounted ( ) {
234
+ if ( typeof ResizeObserver !== 'undefined' ) {
235
+ const obs = new ResizeObserver ( ( ) => {
236
+ this . onResize ( )
237
+ } )
238
+ obs . observe ( this . $el )
239
+ obs . observe ( this . $refs . content )
240
+ this . $on ( 'hook:destroyed' , ( ) => {
241
+ obs . disconnect ( )
242
+ } )
243
+ } else {
244
+ let itemsLength = 0
245
+ this . $on ( 'hook:beforeUpdate' , ( ) => {
246
+ itemsLength = ( this . $refs . content ?. children || [ ] ) . length
247
+ } )
248
+ this . $on ( 'hook:updated' , ( ) => {
249
+ if ( itemsLength === ( this . $refs . content ?. children || [ ] ) . length ) return
250
+ this . setWidths ( )
251
+ } )
252
+ }
241
253
} ,
242
254
243
255
methods : {
Original file line number Diff line number Diff line change @@ -141,6 +141,16 @@ export default baseMixins.extend<options>().extend({
141
141
} ,
142
142
143
143
mounted ( ) {
144
+ if ( typeof ResizeObserver !== 'undefined' ) {
145
+ const obs = new ResizeObserver ( ( ) => {
146
+ this . onResize ( )
147
+ } )
148
+ obs . observe ( this . $el )
149
+ this . $on ( 'hook:destroyed' , ( ) => {
150
+ obs . disconnect ( )
151
+ } )
152
+ }
153
+
144
154
this . $nextTick ( ( ) => {
145
155
window . setTimeout ( this . callSlider , 30 )
146
156
} )
Original file line number Diff line number Diff line change 2635
2635
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.3.tgz#7ee330ba7caafb98090bece86a5ee44115904c2c"
2636
2636
integrity sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==
2637
2637
2638
+ "@types/resize-observer-browser@^0.1.7":
2639
+ version "0.1.7"
2640
+ resolved "https://registry.yarnpkg.com/@types/resize-observer-browser/-/resize-observer-browser-0.1.7.tgz#294aaadf24ac6580b8fbd1fe3ab7b59fe85f9ef3"
2641
+ integrity sha512-G9eN0Sn0ii9PWQ3Vl72jDPgeJwRWhv2Qk/nQkJuWmRmOB4HX3/BhD5SE1dZs/hzPZL/WKnvF0RHdTSG54QJFyg==
2642
+
2638
2643
2639
2644
version "0.0.8"
2640
2645
resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-0.0.8.tgz#f26074d238e02659e323ce1a13d041eee280e194"
You can’t perform that action at this time.
0 commit comments