From 97f24d52fcbe21bad603a44044727dd025a7c30f Mon Sep 17 00:00:00 2001 From: godky Date: Wed, 20 Sep 2023 12:29:48 +0800 Subject: [PATCH 1/2] fix:(Swiper): Fix 'read properties of null' issue when initialize method is returned by isHidden' --- src/swipe/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/swipe/index.js b/src/swipe/index.js index 401db97cd73..8632dded7d8 100644 --- a/src/swipe/index.js +++ b/src/swipe/index.js @@ -146,6 +146,7 @@ export default createComponent({ }, minOffset() { + if (!this.rect) return 0; return ( (this.vertical ? this.rect.height : this.rect.width) - this.size * this.count From 83c85bca80aa21d5ae5580d5450d8c809cd90d10 Mon Sep 17 00:00:00 2001 From: godky Date: Wed, 20 Sep 2023 18:09:58 +0800 Subject: [PATCH 2/2] fix(Swipe):fix swipe auto play when element is hidden --- src/swipe/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/swipe/index.js b/src/swipe/index.js index 8632dded7d8..da5d52977d8 100644 --- a/src/swipe/index.js +++ b/src/swipe/index.js @@ -156,6 +156,7 @@ export default createComponent({ mounted() { this.bindTouchEvent(this.$refs.track); + this.autoPlay(); }, methods: { @@ -385,7 +386,12 @@ export default createComponent({ if (autoplay > 0 && this.count > 1) { this.clear(); this.timer = setTimeout(() => { - this.next(); + if (!this.rect) { + this.initialize(); + } + if (this.rect) { + this.next(); + } this.autoPlay(); }, autoplay); }