中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
本文原创发布在华为开发者社区。
本项目实现了点击、滑动都可实现Tab切换动效,包含文字切换。
Tab动效切换源码链接
安装完成后可以通过点击、滑动查看效果。
.onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => { // 切换动画开始时触发该回调。下划线跟着页面一起滑动,同时宽度渐变。 this.currentIndex = targetIndex let targetIndexInfo = this.getTextInfo(targetIndex) this.startAnimateTo(this.animationDuration, targetIndexInfo.left, targetIndexInfo.width) }) .onAnimationEnd((index: number,event: TabsAnimationEvent) => { // 切换动画结束时触发该回调。下划线动画停止。 let currentIndicatorInfo = this.getCurrentIndicatorInfo(index,event) this.startAnimateTo(0,currentIndicatorInfo.left,currentIndicatorInfo.width) })
.onGestureSwipe((index: number,event: TabsAnimationEvent) => { let currentIndicatorInfo = this.getCurrentIndicatorInfo(index,event) this.currentIndex = currentIndicatorInfo.index this.indicatorLeftMargin = currentIndicatorInfo.left this.indicatorWidth = currentIndicatorInfo.width })
微信扫码分享