Skip to content

Commit 26aebbe

Browse files
wolfibDevtools-frontend LUCI CQ
authored andcommitted
Improve animation for details element
The change makes use of the fact that animating to `height: auto` is possible now. And by using the `details-content` pseudo-element the collapsing is animated as well and not only the expansion. Screencast: https://imgur.com/a/F9zfvxz References: https://developer.chrome.com/docs/css-ui/animate-to-height-auto https://developer.chrome.com/blog/styling-details Bug: none Change-Id: Ibf01944e5ffffcd39a99e819693a49d9fe8ee20d Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6110473 Commit-Queue: Wolfgang Beyer <[email protected]> Reviewed-by: Alex Rudenko <[email protected]>
1 parent 4853e98 commit 26aebbe

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

front_end/panels/explain/components/ConsoleInsight.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ export class ConsoleInsight extends HTMLElement {
587587
.data=${{tokens: this.#state.tokens, renderer: this.#renderer, animationEnabled: true} as MarkdownView.MarkdownView.MarkdownViewData}>
588588
</devtools-markdown-view>`: this.#state.explanation
589589
}
590-
<details style="--list-height: ${(this.#state.sources.length + (this.#state.isPageReloadRecommended ? 1 : 0)) * 20}px;" jslog=${VisualLogging.expand('sources').track({click: true})}>
590+
<details jslog=${VisualLogging.expand('sources').track({click: true})}>
591591
<summary>${i18nString(UIStrings.inputData)}</summary>
592592
<devtools-console-insight-sources-list .sources=${this.#state.sources} .isPageReloadRecommended=${this.#state.isPageReloadRecommended}>
593593
</devtools-console-insight-sources-list>

front_end/panels/explain/components/consoleInsight.css

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,21 @@ summary {
276276
}
277277

278278
details {
279-
--collapsed-height: 20px;
280-
281279
overflow: hidden;
282-
height: var(--collapsed-height);
283280
margin-top: 10px;
284281
}
285282

286-
details[open] {
287-
height: calc(var(--list-height) + var(--collapsed-height) + /* margin */ 8px);
288-
transition: height var(--sys-motion-duration-short4) var(--sys-motion-easing-emphasized);
283+
/* stylelint-disable-next-line selector-pseudo-element-no-unknown */
284+
::details-content {
285+
height: 0;
286+
transition:
287+
height var(--sys-motion-duration-short4) var(--sys-motion-easing-emphasized),
288+
content-visibility var(--sys-motion-duration-short4) var(--sys-motion-easing-emphasized) allow-discrete;
289+
}
290+
291+
/* stylelint-disable-next-line selector-pseudo-element-no-unknown */
292+
[open]::details-content {
293+
height: auto;
289294
}
290295

291296
h2 {

0 commit comments

Comments
 (0)