提交 d90b3379 编写于 作者: Q qiang

feat: swiper 组件增加 transition 事件(H5)

上级 08250ee3
...@@ -371,6 +371,23 @@ export default { ...@@ -371,6 +371,23 @@ export default {
slideFrame.style.transform = transform slideFrame.style.transform = transform
} }
this._viewportPosition = index 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 () { _animateFrameFuncProto () {
if (!this._animating) { if (!this._animating) {
...@@ -387,6 +404,7 @@ export default { ...@@ -387,6 +404,7 @@ export default {
this._updateViewport(toPos) this._updateViewport(toPos)
this._animating = null this._animating = null
this._requestedAnimation = false this._requestedAnimation = false
this._transitionStart = null
var item = this.items[this.currentSync] var item = this.items[this.currentSync]
if (item) { if (item) {
this._itemReady(item, () => { this._itemReady(item, () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册