From d90b3379bf945691a66fc90583784ed6270cb029 Mon Sep 17 00:00:00 2001 From: qiang Date: Mon, 2 Sep 2019 16:15:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20swiper=20=E7=BB=84=E4=BB=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20transition=20=E4=BA=8B=E4=BB=B6=EF=BC=88H5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/view/components/swiper/index.vue | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/core/view/components/swiper/index.vue b/src/core/view/components/swiper/index.vue index 031596bd..73877395 100644 --- a/src/core/view/components/swiper/index.vue +++ b/src/core/view/components/swiper/index.vue @@ -371,6 +371,23 @@ export default { slideFrame.style.transform = transform } this._viewportPosition = index + if (!this._transitionStart) { + if (index % 1 === 0) { + return + } + this._transitionStart = index + } + index -= Math.floor(this._transitionStart) + if (index <= -(this.items.length - 1)) { + index += this.items.length + } else if (index >= this.items.length) { + index -= this.items.length + } + index = this._transitionStart % 1 > 0.5 || this._transitionStart < 0 ? index - 1 : index + this.$trigger('transition', {}, { + dx: this.vertical ? 0 : index * slideFrame.offsetWidth, + dy: this.vertical ? index * slideFrame.offsetHeight : 0 + }) }, _animateFrameFuncProto () { if (!this._animating) { @@ -387,6 +404,7 @@ export default { this._updateViewport(toPos) this._animating = null this._requestedAnimation = false + this._transitionStart = null var item = this.items[this.currentSync] if (item) { this._itemReady(item, () => { -- GitLab