@@ -43,7 +43,7 @@ export default defineComponent({
4343 const isSwitching = ref ( false ) ;
4444 const showArrow = ref ( false ) ;
4545 const swiperWrap = ref < HTMLElement > ( ) ;
46- const wrapOffsetWidth = ref ( 0 ) ;
46+ const wrapOffset = ref ( { width : 0 , height : 0 } ) ;
4747 const swiperItemLength = ref ( 0 ) ;
4848
4949 const getChildComponentByName = useChildComponentSlots ( ) ;
@@ -74,7 +74,7 @@ export default defineComponent({
7474 } ;
7575 } ) ;
7676 const containerStyle = computed ( ( ) => {
77- const offsetHeight = props . height ? `${ props . height } px` : `${ getWrapAttribute ( 'offsetHeight' ) } px` ;
77+ const offsetHeight = props . height ? `${ props . height } px` : `${ wrapOffset . value . height } px` ;
7878 if ( props . type === 'card' || props . animation === 'fade' ) {
7979 return {
8080 height : offsetHeight ,
@@ -114,7 +114,7 @@ export default defineComponent({
114114 index = { index }
115115 currentIndex = { currentIndex . value }
116116 isSwitching = { isSwitching . value }
117- offsetWidth = { wrapOffsetWidth . value }
117+ offsetWidth = { wrapOffset . value . width }
118118 swiperItemLength = { swiperItemLength . value }
119119 { ...p }
120120 >
@@ -229,9 +229,6 @@ export default defineComponent({
229229 }
230230 return swiperTo ( currentIndex . value - 1 , context ) ;
231231 } ;
232- const getWrapAttribute = ( attr : string ) => {
233- return swiperWrap . value ?. parentNode ?. [ attr as keyof ParentNode ] ;
234- } ;
235232 const renderPagination = ( ) => {
236233 const fractionIndex = currentIndex . value + 1 > swiperItemLength . value ? 1 : currentIndex . value + 1 ;
237234 return (
@@ -343,7 +340,10 @@ export default defineComponent({
343340 useResizeObserver ( swiperWrap , ( ) => {
344341 const parentElement = swiperWrap . value ?. parentNode as HTMLElement ;
345342 if ( parentElement ) {
346- wrapOffsetWidth . value = parentElement . offsetWidth || 0 ;
343+ wrapOffset . value = {
344+ width : parentElement . offsetWidth || 0 ,
345+ height : parentElement . offsetHeight || 0 ,
346+ } ;
347347 }
348348 } ) ;
349349
0 commit comments