Skip to content

Commit

Permalink
Start to adopt "Reduced Motion" ref #128595
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackson Kearl committed Jul 14, 2021
1 parent 1fa030e commit f76d07f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ configurationRegistry.registerConfiguration({
type: 'boolean',
default: true,
description: localize('workbench.welcomePage.walkthroughs.openOnInstall', "When enabled, an extension's walkthrough will open upon install the extension.")
},
'workbench.welcomePage.preferReducedMotion': {
scope: ConfigurationScope.APPLICATION,
type: 'boolean',
default: false,
description: localize('workbench.welcomePage.preferReducedMotion', "When enabled, reduce motion in welcome page.")
}
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
padding: 12px 24px;
}

.monaco-workbench .part.editor>.content .gettingStartedContainer.animationReady .gettingStartedSlide {
.monaco-workbench .part.editor>.content .gettingStartedContainer.animatable .gettingStartedSlide {
/* keep consistant with SLIDE_TRANSITION_TIME_MS in gettingStarted.ts */
transition: left 0.25s, opacity 0.25s;
}
Expand Down Expand Up @@ -363,6 +363,9 @@
width: 100%;
margin: 4px 0;
overflow: hidden;
}

.monaco-workbench .part.editor>.content .gettingStartedContainer.animatable .gettingStartedSlideDetails .getting-started-step {
transition: height .1s linear;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type GettingStartedActionEvent = {
argument: string | undefined;
};

const REDUCED_MOTION_KEY = 'workbench.welcomePage.preferReducedMotion';
export class GettingStartedPage extends EditorPane {

public static readonly ID = 'gettingStartedPage';
Expand Down Expand Up @@ -218,6 +219,12 @@ export class GettingStartedPage extends EditorPane {
this.hideCategory(category.id);
}

this._register(this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(REDUCED_MOTION_KEY)) {
this.container.classList.toggle('animatable', this.shouldAnimate());
}
}));

ourStep.done = step.done;
if (category.id === this.currentCategory?.id) {
const badgeelements = assertIsDefined(document.querySelectorAll(`[data-done-step-id="${step.id}"]`));
Expand All @@ -240,12 +247,18 @@ export class GettingStartedPage extends EditorPane {
this.recentlyOpened = workspacesService.getRecentlyOpened();
}

private shouldAnimate() {
return !this.configurationService.getValue(REDUCED_MOTION_KEY);
}

override async setInput(newInput: GettingStartedInput, options: IEditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken) {
this.container.classList.remove('animationReady');
this.container.classList.remove('animatable');
this.editorInput = newInput;
await super.setInput(newInput, options, context, token);
await this.buildCategoriesSlide();
setTimeout(() => this.container.classList.add('animationReady'), 0);
if (this.shouldAnimate()) {
setTimeout(() => this.container.classList.add('animatable'), 0);
}
}

async makeCategoryVisibleWhenAvailable(categoryID: string, stepId?: string) {
Expand Down

0 comments on commit f76d07f

Please sign in to comment.