TASK: #115114 - 容器组件添加页面切换结束回调功能
This commit is contained in:
parent
60632013f3
commit
d1b1313b5e
|
@ -343,30 +343,34 @@ class GaiaContainer extends StarBaseElement {
|
|||
event.type === 'swipeleft' ? this.turnNext('swipe') : this.turnPre('swipe')
|
||||
}
|
||||
|
||||
turnPre(type: string) {
|
||||
turnPre(type: string, callback?: Function) {
|
||||
if (this.pagination <= 0) {
|
||||
this.pagination = 0
|
||||
} else {
|
||||
this.status |= STATUS.TURN
|
||||
this.pagination--
|
||||
}
|
||||
this.resetView(type)
|
||||
this.resetView(type, this.pagination, callback)
|
||||
}
|
||||
|
||||
turnNext(type: string) {
|
||||
turnNext(type: string, callback?: Function) {
|
||||
if (this.pagination < this.pages.length - 1) {
|
||||
this.pagination++
|
||||
this.status |= STATUS.TURN
|
||||
} else {
|
||||
this.pagination = this.pages.length - 1
|
||||
}
|
||||
this.resetView(type)
|
||||
this.resetView(type, this.pagination, callback)
|
||||
}
|
||||
|
||||
resetView(type: string, pagination = this.pagination): boolean {
|
||||
resetView(
|
||||
type: string,
|
||||
pagination = this.pagination,
|
||||
callback?: Function
|
||||
): boolean {
|
||||
const target: HTMLElement = (this.pages as any)[pagination]
|
||||
if (!target && pagination > 0) return this.resetView(type, --pagination)
|
||||
this.smoothSlide(target, type)
|
||||
this.smoothSlide(target, type, callback)
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -377,7 +381,7 @@ class GaiaContainer extends StarBaseElement {
|
|||
// 触发划动的原因类型
|
||||
slideType: string = ''
|
||||
|
||||
smoothSlide(element: HTMLElement, type: string) {
|
||||
smoothSlide(element: HTMLElement, type: string, callback?: Function) {
|
||||
if (
|
||||
!element ||
|
||||
this.typeIndex.indexOf(this.slideType) > this.typeIndex.indexOf(type)
|
||||
|
@ -446,6 +450,7 @@ class GaiaContainer extends StarBaseElement {
|
|||
this.status &= ~STATUS.SWIPE
|
||||
// 如果处于拖拽状态则更新一次落点位置
|
||||
this.continueDrag()
|
||||
callback?.()
|
||||
} else if (this.timer) {
|
||||
this.timer()
|
||||
}
|
||||
|
@ -626,6 +631,7 @@ class GaiaContainer extends StarBaseElement {
|
|||
pagination: number = this.pagination
|
||||
) {
|
||||
let page = this.pages[pagination]
|
||||
const {width, height} = page.getBoundingClientRect()
|
||||
|
||||
x += page.scrollLeft - page.offsetLeft
|
||||
y += page.scrollTop - page.offsetTop
|
||||
|
@ -633,6 +639,10 @@ class GaiaContainer extends StarBaseElement {
|
|||
x = x < 0 ? 0 : x
|
||||
y = y < 0 ? 0 : y
|
||||
|
||||
// 越界时,需要将落点坐标退回到分页内部
|
||||
x = x > width ? width - 1 : x
|
||||
y = y > height ? height - 1 : y
|
||||
|
||||
const coordinateX = parseInt(String(x / Math.floor(this.gridWidth)))
|
||||
const coordinateY = parseInt(String(y / Math.floor(this.gridHeight)))
|
||||
const gridId = coordinateX + coordinateY * this.column
|
||||
|
@ -1306,7 +1316,6 @@ class GaiaContainer extends StarBaseElement {
|
|||
this.removeTailPage()
|
||||
this._dnd.child = null
|
||||
this._dnd.isSpanning = false
|
||||
this.status &= ~STATUS.DRAG
|
||||
this.exchangeStratege.reset()
|
||||
this.synchronise()
|
||||
}
|
||||
|
@ -1996,6 +2005,7 @@ class GaiaContainer extends StarBaseElement {
|
|||
) {
|
||||
this.handleEnd(event)
|
||||
} else {
|
||||
this.status &= ~STATUS.DRAG
|
||||
this.endDrag(event)
|
||||
}
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue