From 9d407d8c9304ece4055bed9519032f3095dd1c8e Mon Sep 17 00:00:00 2001 From: huqiyao <2097420261@qq.com> Date: Wed, 11 Sep 2024 17:41:35 +0800 Subject: [PATCH 1/2] fix book flip scale --- .../BookFlipLongTakeTransitionProperties.ets | 14 ++++++++------ .../BookFlipLongTakeTransitionPageTwo.ets | 6 ++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/AnimationDemos/entry/src/main/ets/common/utils/customtransition/BookFlipLongTakeTransitionProperties.ets b/AnimationDemos/entry/src/main/ets/common/utils/customtransition/BookFlipLongTakeTransitionProperties.ets index 7078dda..25b603e 100644 --- a/AnimationDemos/entry/src/main/ets/common/utils/customtransition/BookFlipLongTakeTransitionProperties.ets +++ b/AnimationDemos/entry/src/main/ets/common/utils/customtransition/BookFlipLongTakeTransitionProperties.ets @@ -59,8 +59,10 @@ export class BookFlipLongTakeTransitionProperties { public coverTranslateX: number = 0; public clipWidth: Dimension = 0; public clipHeight: Dimension = 0; - public contentScaleY?: number = undefined - public contentScaleX?: number = undefined + public contentScaleY: number = 1; + public contentScaleX: number = 1; + public contentHeight: Dimension = '100%'; + public contentWidth: Dimension = '100%' public doAnimation(fromCardItemInfo_px: RectInfoInPx, toCardItemInfo_px: RectInfoInPx): void { @@ -161,8 +163,8 @@ export class BookFlipLongTakeTransitionProperties { this.translateY = 0; this.rotateAngle = -90; this.coverScale = 0; - this.contentScaleX = undefined; - this.contentScaleY = undefined; + this.contentScaleX = 1; + this.contentScaleY = 1; } }) } @@ -193,12 +195,14 @@ export class BookFlipLongTakeTransitionProperties { this.clipHeight = initClipHeight; this.scaleYValue = initScaleYValue; this.translateY = deltaTranslateY; + this.contentHeight = px2vp(WindowUtils.windowHeight_px); this.contentScaleY = 1 / this.scaleYValue; // 抵消容器scale带来内容的变形 } if (this.clipWidth !== initClipWidth && !initInfo.isUseWidthScale) { this.clipWidth = initClipWidth; this.scaleXValue = initScaleXValue; this.translateX = deltaTranslateX; + this.contentWidth = px2vp(WindowUtils.windowWidth_px); this.contentScaleX = 1 / this.scaleXValue; } @@ -208,14 +212,12 @@ export class BookFlipLongTakeTransitionProperties { if (initInfo.isUseWidthScale) { this.scaleXValue = 1 - (1 - initScale) * progress; this.scaleYValue = initScaleYValue + (initScale - initScaleYValue) * progress; - this.contentScaleY = 1 / this.scaleYValue * this.scaleXValue; this.translateX = initTranslateX * progress; this.translateY = deltaTranslateY * (1 - progress) + initTranslateY * progress; } else { this.scaleYValue = 1 - (1 - initScale) * progress; this.scaleXValue = initScaleYValue + (initScale - initScaleYValue) * progress; this.contentScaleX = 1 / this.scaleXValue * this.scaleYValue; - this.translateY = initTranslateY * progress; this.translateX = deltaTranslateX * (1 - progress) + initTranslateX * progress; } this.coverScale = progress; diff --git a/AnimationDemos/entry/src/main/ets/pages/Transition/LongTakeTransition/BookFlipLongTakeTransition/BookFlipLongTakeTransitionPageTwo.ets b/AnimationDemos/entry/src/main/ets/pages/Transition/LongTakeTransition/BookFlipLongTakeTransition/BookFlipLongTakeTransitionPageTwo.ets index 2ee6390..d3b50e1 100644 --- a/AnimationDemos/entry/src/main/ets/pages/Transition/LongTakeTransition/BookFlipLongTakeTransition/BookFlipLongTakeTransitionPageTwo.ets +++ b/AnimationDemos/entry/src/main/ets/pages/Transition/LongTakeTransition/BookFlipLongTakeTransition/BookFlipLongTakeTransitionPageTwo.ets @@ -68,15 +68,17 @@ export struct BookFlipLongTakeTransitionPageTwo { build() { NavDestination() { Stack() { - Stack() { + Column() { Text($r('app.string.DetailPage_text')) .fontColor(Color.White) } + .justifyContent(FlexAlign.Center) + .width(this.bookFlipLongTakeTransitionProperties.contentWidth) + .height(this.bookFlipLongTakeTransitionProperties.clipHeight) .scale({ y: this.bookFlipLongTakeTransitionProperties.contentScaleY, x: this.bookFlipLongTakeTransitionProperties.contentScaleX }) - .width('100%') if (!this.doDefaultTransition) { Image($r(this.bookCoverUrl)) -- Gitee From 7207bb4ed6c3caeeaceb6d1ef7db79c05dc98dcf Mon Sep 17 00:00:00 2001 From: huqiyao <2097420261@qq.com> Date: Thu, 12 Sep 2024 19:37:43 +0800 Subject: [PATCH 2/2] initial status --- .../customtransition/BookFlipLongTakeTransitionProperties.ets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AnimationDemos/entry/src/main/ets/common/utils/customtransition/BookFlipLongTakeTransitionProperties.ets b/AnimationDemos/entry/src/main/ets/common/utils/customtransition/BookFlipLongTakeTransitionProperties.ets index 25b603e..f09224d 100644 --- a/AnimationDemos/entry/src/main/ets/common/utils/customtransition/BookFlipLongTakeTransitionProperties.ets +++ b/AnimationDemos/entry/src/main/ets/common/utils/customtransition/BookFlipLongTakeTransitionProperties.ets @@ -163,6 +163,8 @@ export class BookFlipLongTakeTransitionProperties { this.translateY = 0; this.rotateAngle = -90; this.coverScale = 0; + this.contentHeight = '100%'; + this.contentWidth = '100%'; this.contentScaleX = 1; this.contentScaleY = 1; } -- Gitee