Skip to content

Commit

Permalink
Add page transition animations to Privacy Guide
Browse files Browse the repository at this point in the history
Adds a new type of animation to cr-view-manager: "slide-in-fade-in".
This is inspired by the proof-of-concept CL here:
https://chromium-review.googlesource.com/c/chromium/src/+/3229607

This animation is then used in the Privacy Guide.

Bug: 1215630
Change-Id: Idad17ecb1ea6a6e15d0d2576e9f67ad4094c6af3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3396156
Reviewed-by: Rainhard Findling <rainhard@chromium.org>
Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Martin Šrámek <msramek@chromium.org>
Cr-Commit-Position: refs/heads/main@{#960565}
  • Loading branch information
msramek authored and Chromium LUCI CQ committed Jan 18, 2022
1 parent 1a9d8ba commit 1252605
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,8 @@ export class SettingsPrivacyReviewPageElement extends PrivacyReviewBase {
}
} else {
if (this.animationsEnabled_ && playAnimation) {
this.$.viewManager.switchView(this.privacyReviewStep_);
this.$.viewManager.switchView(
this.privacyReviewStep_, 'slide-in-fade-in', 'no-animation');
} else {
this.$.viewManager.switchView(
this.privacyReviewStep_, 'no-animation', 'no-animation');
Expand Down
21 changes: 15 additions & 6 deletions ui/webui/resources/cr_elements/cr_view_manager/cr_view_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ function dispatchCustomEvent(element, eventType) {
/** @type {!Map<string, function(!Element): !Promise>} */
const viewAnimations = new Map();
viewAnimations.set('fade-in', element => {
// The call to animate can have 2 methods of passing the keyframes, however as
// of the current closure version, only one of them is supported. See
// https://crbug.com/987842 for more info.
const animation = element.animate(
[{opacity: 0}, {opacity: 1}],
/** @type {!KeyframeAnimationOptions } */ ({
Expand All @@ -53,9 +50,6 @@ viewAnimations.set('fade-in', element => {
return whenFinished(animation);
});
viewAnimations.set('fade-out', element => {
// The call to animate can have 2 methods of passing the keyframes, however as
// of the current closure version, only one of them is supported. See
// https://crbug.com/987842 for more info.
const animation = element.animate(
[{opacity: 1}, {opacity: 0}],
/** @type {!KeyframeAnimationOptions} */ ({
Expand All @@ -66,6 +60,21 @@ viewAnimations.set('fade-out', element => {

return whenFinished(animation);
});
viewAnimations.set('slide-in-fade-in', element => {
const animation = element.animate(
[
{transform: 'translateX(8px)', opacity: 0},
{transform: 'translateX(0)', opacity: 1}
],
/** @type {!KeyframeAnimationOptions} */ ({
duration: 300,
easing: 'cubic-bezier(0.0, 0.0, 0.2, 1)',
fill: 'forwards',
iterations: 1,
}));

return whenFinished(animation);
});

/** @polymer */
export class CrViewManagerElement extends PolymerElement {
Expand Down

0 comments on commit 1252605

Please sign in to comment.