web:Add slider call callback

This commit is contained in:
pengfei.zhou
2021-04-22 11:47:08 +08:00
committed by osborn
parent e7ced92281
commit 819feb1617
3 changed files with 34 additions and 6 deletions

View File

@@ -69,11 +69,17 @@ export class DoricSliderNode extends DoricSuperNode {
})
}
ret.ontouchcancel = ret.ontouchend = () => {
let originInndex = currentIndex
currentIndex = Math.round(ret.scrollLeft / ret.offsetWidth)
ret.scrollTo({
left: currentIndex * ret.offsetWidth,
behavior: "smooth"
})
if (originInndex !== currentIndex) {
if (this.onPageSelectedFuncId.length > 0) {
this.callJSResponse(this.onPageSelectedFuncId, currentIndex)
}
}
}
return ret
}