
温馨提示:本篇博客的详细代码已发布到 git : https://gitcode.com/nutpi/HarmonyosNext 可以下载运行哦!


private scroller: Scroller = new Scroller();
Scroll(this.scroller) {
Column() {
// 滚动内容
}
}.onWillScroll(() => {
let yOffset = this.scroller.currentOffset().yOffset;
this.headerOpacity = Math.min(1, yOffset / 100);
})customContentTransition({
timeout: 1000,
transition: (proxy: SwiperContentTransitionProxy) => {
let angle = proxy.position * 90;
this.angleList[proxy.index] = angle;
this.centerXList[proxy.index] = proxy.position < 0 ? '100%' : '0%';
}
}).onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => {
if (index === targetIndex) {
return;
}
this.currentIndex = targetIndex;
}).backgroundColor(`rgba(255, 255, 255, ${this.headerOpacity})`)
// 图标颜色切换
Image(this.headerOpacity < 0.5 ?
$r('app.media.cube_animation_scan_white') :
$r('app.media.cube_animation_scan_black'))this.headerOpacity = Math.min(1, yOffset / 100);Swiper(this.swiperController) {
ForEach(this.bannerItems, (item: Resource) => {
Image(item)
})
}
.autoPlay(true)
.indicator(new DotIndicator())CubeRotateAnimationSwiper({
items: item,
cubeSwiperController: this.cubeSwiperControllers[index],
swiperItemSlotParam: (item: MySwiperItem) => {
this.mySwiperItem(item);
}
})// 3D轮播超时设置
timeout: 1000,
// Tab切换动画
.barAnimationDuration(300).curve(Curve.EaseInOut)
.duration(this.duration)本篇教程详细介绍了:
下一篇将介绍事件处理机制的实现细节。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。