From b935487cb9653e84df5460df173f7687c45d2feb Mon Sep 17 00:00:00 2001 From: Matias Szylkowski Date: Thu, 22 Jul 2021 12:06:04 -0400 Subject: [PATCH 1/5] Added experiment --- .../global-configs/canary-config.json | 1 + build-system/global-configs/prod-config.json | 1 + extensions/amp-story/1.0/animation.js | 20 +++++++++++++------ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/build-system/global-configs/canary-config.json b/build-system/global-configs/canary-config.json index bb1ef69297e5..9c98fa4a17f8 100644 --- a/build-system/global-configs/canary-config.json +++ b/build-system/global-configs/canary-config.json @@ -21,5 +21,6 @@ "story-ad-auto-advance": 1, "story-ad-placements": 1, "story-load-first-page-only": 0.1, + "story-disable-animations-first-page": 0.1, "amp-story-page-attachment-ui-v2": 1 } diff --git a/build-system/global-configs/prod-config.json b/build-system/global-configs/prod-config.json index fb8d8e2e4403..712941ca6d50 100644 --- a/build-system/global-configs/prod-config.json +++ b/build-system/global-configs/prod-config.json @@ -17,6 +17,7 @@ "amp-consent-granular-consent": 1, "amp-cid-backup": 1, "story-ad-placements": 0.01, + "story-disable-animations-first-page": 0.1, "story-load-first-page-only": 0.1, "amp-story-page-attachment-ui-v2": 1 } diff --git a/extensions/amp-story/1.0/animation.js b/extensions/amp-story/1.0/animation.js index 8ecacc591ca2..ebe25e723067 100644 --- a/extensions/amp-story/1.0/animation.js +++ b/extensions/amp-story/1.0/animation.js @@ -38,9 +38,14 @@ import {escapeCssSelectorIdent} from '#core/dom/css-selectors'; import {getChildJsonConfig} from '../../../src/json'; import {map, omit} from '#core/types/object'; import {prefersReducedMotion} from '#core/dom/media-query-props'; -import {scopedQuerySelector, scopedQuerySelectorAll} from '#core/dom/query'; +import { + matches, + scopedQuerySelector, + scopedQuerySelectorAll, +} from '#core/dom/query'; import {setStyles} from '#core/dom/style'; import {timeStrToMillis, unscaledClientRect} from './utils'; +import {isExperimentOn} from '#experiments'; const TAG = 'AMP-STORY'; @@ -554,7 +559,10 @@ export class AnimationManager { this.builderPromise_ = this.createAnimationBuilderPromise_(); /** @private @const {bool} */ - this.prefersReducedMotion_ = prefersReducedMotion(ampdoc.win); + this.skipAnimations_ = + prefersReducedMotion(ampdoc.win) || + (isExperimentOn(ampdoc.win, 'story-disable-animations-first-page') && + matches(page, 'amp-story-page:first-of-type')); /** @private {?Array} */ this.runners_ = null; @@ -581,7 +589,7 @@ export class AnimationManager { applyFirstFrameOrFinish() { return Promise.all( this.getOrCreateRunners_().map((runner) => - this.prefersReducedMotion_ + this.skipAnimations_ ? runner.applyLastFrame() : runner.applyFirstFrame() ) @@ -600,7 +608,7 @@ export class AnimationManager { /** Starts all entrance animations for the page. */ animateIn() { - if (this.prefersReducedMotion_) { + if (this.skipAnimations_) { return; } this.getRunners_().forEach((runner) => runner.start()); @@ -622,7 +630,7 @@ export class AnimationManager { /** Pauses all animations in the page. */ pauseAll() { - if (!this.runners_ || this.prefersReducedMotion_) { + if (!this.runners_ || this.skipAnimations_) { return; } this.getRunners_().forEach((runner) => runner.pause()); @@ -630,7 +638,7 @@ export class AnimationManager { /** Resumes all animations in the page. */ resumeAll() { - if (!this.runners_ || this.prefersReducedMotion_) { + if (!this.runners_ || this.skipAnimations_) { return; } this.getRunners_().forEach((runner) => runner.resume()); From c992fcc50882834a46c269677805ee09c9d3b52a Mon Sep 17 00:00:00 2001 From: Matias Szylkowski Date: Thu, 22 Jul 2021 12:14:13 -0400 Subject: [PATCH 2/5] Change experiment rollout percentage --- build-system/global-configs/canary-config.json | 2 +- build-system/global-configs/prod-config.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build-system/global-configs/canary-config.json b/build-system/global-configs/canary-config.json index 9c98fa4a17f8..900664f49090 100644 --- a/build-system/global-configs/canary-config.json +++ b/build-system/global-configs/canary-config.json @@ -21,6 +21,6 @@ "story-ad-auto-advance": 1, "story-ad-placements": 1, "story-load-first-page-only": 0.1, - "story-disable-animations-first-page": 0.1, + "story-disable-animations-first-page": 0.05, "amp-story-page-attachment-ui-v2": 1 } diff --git a/build-system/global-configs/prod-config.json b/build-system/global-configs/prod-config.json index 712941ca6d50..6dbe0b717ac9 100644 --- a/build-system/global-configs/prod-config.json +++ b/build-system/global-configs/prod-config.json @@ -17,7 +17,7 @@ "amp-consent-granular-consent": 1, "amp-cid-backup": 1, "story-ad-placements": 0.01, - "story-disable-animations-first-page": 0.1, + "story-disable-animations-first-page": 0.05, "story-load-first-page-only": 0.1, "amp-story-page-attachment-ui-v2": 1 } From 67fdb9f7babc61884059cca455d7deff7073e3c9 Mon Sep 17 00:00:00 2001 From: Matias Szylkowski Date: Thu, 22 Jul 2021 13:37:59 -0400 Subject: [PATCH 3/5] Add to CSI metrics --- extensions/amp-story/1.0/amp-story.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/extensions/amp-story/1.0/amp-story.js b/extensions/amp-story/1.0/amp-story.js index d06e9d3f2899..a40f66dc305a 100644 --- a/extensions/amp-story/1.0/amp-story.js +++ b/extensions/amp-story/1.0/amp-story.js @@ -465,6 +465,11 @@ export class AmpStory extends AMP.BaseElement { 'story-load-first-page-only' ); } + if (isExperimentOn(this.win, 'story-disable-animations-first-page')) { + Services.performanceFor(this.win).addEnabledExperiment( + 'story-load-first-page-only' + ); + } if (this.maybeLoadStoryDevTools_()) { return; From 7bac348b9232713f97dfff32511e3baaa4991dbd Mon Sep 17 00:00:00 2001 From: Matias Szylkowski Date: Thu, 22 Jul 2021 14:06:31 -0400 Subject: [PATCH 4/5] Trigger experiment with reduced-motion --- extensions/amp-story/1.0/amp-story.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/extensions/amp-story/1.0/amp-story.js b/extensions/amp-story/1.0/amp-story.js index a40f66dc305a..0e567b679c74 100644 --- a/extensions/amp-story/1.0/amp-story.js +++ b/extensions/amp-story/1.0/amp-story.js @@ -59,6 +59,7 @@ import {CSS} from '../../../build/amp-story-1.0.css'; import {CommonSignals} from '#core/constants/common-signals'; import {EventType, dispatch} from './events'; import {Gestures} from '../../../src/gesture'; +import {prefersReducedMotion} from '#core/dom/media-query-props'; import {HistoryState, getHistoryState, setHistoryState} from './history'; import {InfoDialog} from './amp-story-info-dialog'; import {Keys} from '#core/constants/key-codes'; @@ -465,9 +466,12 @@ export class AmpStory extends AMP.BaseElement { 'story-load-first-page-only' ); } - if (isExperimentOn(this.win, 'story-disable-animations-first-page')) { + if ( + isExperimentOn(this.win, 'story-disable-animations-first-page') || + prefersReducedMotion(this.win) + ) { Services.performanceFor(this.win).addEnabledExperiment( - 'story-load-first-page-only' + 'story-disable-animations-first-page' ); } From 036b51272d849a1c6ba396bdbcf6f8f7a8ece3b9 Mon Sep 17 00:00:00 2001 From: Matias Szylkowski Date: Thu, 22 Jul 2021 15:54:21 -0400 Subject: [PATCH 5/5] Change experiment to 10% --- build-system/global-configs/canary-config.json | 2 +- build-system/global-configs/prod-config.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build-system/global-configs/canary-config.json b/build-system/global-configs/canary-config.json index 900664f49090..9c98fa4a17f8 100644 --- a/build-system/global-configs/canary-config.json +++ b/build-system/global-configs/canary-config.json @@ -21,6 +21,6 @@ "story-ad-auto-advance": 1, "story-ad-placements": 1, "story-load-first-page-only": 0.1, - "story-disable-animations-first-page": 0.05, + "story-disable-animations-first-page": 0.1, "amp-story-page-attachment-ui-v2": 1 } diff --git a/build-system/global-configs/prod-config.json b/build-system/global-configs/prod-config.json index 6dbe0b717ac9..712941ca6d50 100644 --- a/build-system/global-configs/prod-config.json +++ b/build-system/global-configs/prod-config.json @@ -17,7 +17,7 @@ "amp-consent-granular-consent": 1, "amp-cid-backup": 1, "story-ad-placements": 0.01, - "story-disable-animations-first-page": 0.05, + "story-disable-animations-first-page": 0.1, "story-load-first-page-only": 0.1, "amp-story-page-attachment-ui-v2": 1 }