From a05151e39164dccb4f8c12e67a8a4bc25f5a242f Mon Sep 17 00:00:00 2001 From: leejimqiu Date: Tue, 10 Jan 2023 17:27:08 +0800 Subject: [PATCH] fix(collapse): enables nested use --- src/collapse-panel/collapse-panel.less | 2 +- src/collapse-panel/collapse-panel.ts | 6 ++-- .../__test__/__snapshots__/index.test.js.snap | 33 +++++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/collapse-panel/collapse-panel.less b/src/collapse-panel/collapse-panel.less index 7ed60bbeb..380ae0986 100644 --- a/src/collapse-panel/collapse-panel.less +++ b/src/collapse-panel/collapse-panel.less @@ -18,7 +18,6 @@ @collapse-panel-bg-color: var(--td-collapse-panel-bg-color, @bg-color-block); .@{prefix}-collapse-panel { - overflow: hidden; .border(bottom, @collapse-border-color); background-color: @collapse-panel-bg-color; @@ -83,6 +82,7 @@ &__wrapper { height: 0; + overflow: hidden; } &__content { diff --git a/src/collapse-panel/collapse-panel.ts b/src/collapse-panel/collapse-panel.ts index 124d82956..8dd950fac 100644 --- a/src/collapse-panel/collapse-panel.ts +++ b/src/collapse-panel/collapse-panel.ts @@ -70,14 +70,14 @@ export default class CollapsePanel extends SuperComponent { .then((rect: WechatMiniprogram.BoundingClientRectCallbackResult) => rect.height) .then((height: number) => { const animation = wx.createAnimation({ - duration: 300, + duration: 0, timingFunction: 'ease-in-out', }); if (expanded) { - animation.height(height).step(); + animation.height(height).top(0).step({ duration: 300 }).height('auto').step(); } else { - animation.height(0).step(); + animation.height(height).top(1).step({ duration: 1 }).height(0).step({ duration: 300 }); } this.setData({ animation: animation.export() }); diff --git a/src/collapse/__test__/__snapshots__/index.test.js.snap b/src/collapse/__test__/__snapshots__/index.test.js.snap index 8f991e03d..d1bda6f6b 100644 --- a/src/collapse/__test__/__snapshots__/index.test.js.snap +++ b/src/collapse/__test__/__snapshots__/index.test.js.snap @@ -643,6 +643,13 @@ exports[`collapse :disabled 1`] = ` ], "type": "style", }, + Object { + "args": Array [ + "top", + "0px", + ], + "type": "style", + }, ], "option": Object { "transformOrigin": "50% 50% 0", @@ -653,6 +660,32 @@ exports[`collapse :disabled 1`] = ` }, }, }, + Object { + "animates": Array [ + Object { + "args": Array [ + "height", + "auto", + ], + "type": "style", + }, + Object { + "args": Array [ + "top", + "0px", + ], + "type": "style", + }, + ], + "option": Object { + "transformOrigin": "50% 50% 0", + "transition": Object { + "delay": 0, + "duration": 0, + "timingFunction": "ease-in-out", + }, + }, + }, ], } }}"