mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 10:52:45 +08:00
DEV: Delay rendering sidebar sections after sidebar is shown (#27227)
Delay rendering sidebar sections after sidebar is shown Showing the popup takes about 100ms, then rendering each section could take up to and additional 200ms, which leaves the total just outside of 300ms. If we cheat by rendering the popup first then the sections in the next frame, it improves our paint time Introduce DeferredRender to encapsulate 'paint later'
This commit is contained in:
parent
2ed8f96e67
commit
7aa5c64806
|
@ -0,0 +1,18 @@
|
|||
import Component from "@glimmer/component";
|
||||
import { tracked } from "@glimmer/tracking";
|
||||
import runAfterFramePaint from "discourse/lib/after-frame-paint";
|
||||
|
||||
export default class DeferredRender extends Component {
|
||||
@tracked shouldRender = false;
|
||||
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
runAfterFramePaint(() => (this.shouldRender = true));
|
||||
}
|
||||
|
||||
<template>
|
||||
{{#if this.shouldRender}}
|
||||
{{yield}}
|
||||
{{/if}}
|
||||
</template>
|
||||
}
|
|
@ -3,6 +3,7 @@ import { action } from "@ember/object";
|
|||
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
|
||||
import { service } from "@ember/service";
|
||||
import { or } from "truth-helpers";
|
||||
import DeferredRender from "discourse/components/deferred-render";
|
||||
import ApiPanels from "./api-panels";
|
||||
import Footer from "./footer";
|
||||
import Sections from "./sections";
|
||||
|
@ -39,25 +40,26 @@ export default class SidebarHamburgerDropdown extends Component {
|
|||
>
|
||||
<div class="panel-body">
|
||||
<div class="panel-body-contents">
|
||||
<div class="sidebar-hamburger-dropdown">
|
||||
{{#if
|
||||
(or this.sidebarState.showMainPanel @forceMainSidebarPanel)
|
||||
}}
|
||||
<Sections
|
||||
@currentUser={{this.currentUser}}
|
||||
@collapsableSections={{this.collapsableSections}}
|
||||
@panel={{this.sidebarState.currentPanel}}
|
||||
@hideApiSections={{@forceMainSidebarPanel}}
|
||||
/>
|
||||
{{else}}
|
||||
<ApiPanels
|
||||
@currentUser={{this.currentUser}}
|
||||
@collapsableSections={{this.collapsableSections}}
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
<DeferredRender>
|
||||
<div class="sidebar-hamburger-dropdown">
|
||||
{{#if
|
||||
(or this.sidebarState.showMainPanel @forceMainSidebarPanel)
|
||||
}}
|
||||
<Sections
|
||||
@currentUser={{this.currentUser}}
|
||||
@collapsableSections={{this.collapsableSections}}
|
||||
@panel={{this.sidebarState.currentPanel}}
|
||||
@hideApiSections={{@forceMainSidebarPanel}}
|
||||
/>
|
||||
{{else}}
|
||||
<ApiPanels
|
||||
@currentUser={{this.currentUser}}
|
||||
@collapsableSections={{this.collapsableSections}}
|
||||
/>
|
||||
{{/if}}
|
||||
<Footer />
|
||||
</div>
|
||||
</DeferredRender>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user