Skip to content

Commit

Permalink
Split Twitter placeholder flags. (#17527)
Browse files Browse the repository at this point in the history
- Use a separate flag for each aspect of the default placeholder so that
we can try different combinations.
  • Loading branch information
Sepand Parhami committed Aug 16, 2018
1 parent ba77535 commit 5798e1e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions extensions/amp-twitter/0.1/amp-twitter.css
Expand Up @@ -55,7 +55,7 @@ amp-twitter {
height: 100%;
}

.i-amphtml-twitter-pulse .i-amphtml-twitter-placeholder-svg {
.i-amphtml-twitter-pulse:not([i-amphtml-loading]) .i-amphtml-twitter-placeholder-svg {
transition-property: transform, opacity;
transition-duration: 100ms;
transition-timing-function: ease-in;
Expand Down Expand Up @@ -97,7 +97,7 @@ amp-twitter[i-amphtml-loading="done"] .i-amphtml-twitter-placeholder-svg {
opacity: 0;
}

.i-amphtml-twitter-pulse[i-amphtml-loading="done"] .i-amphtml-twitter-placeholder-svg {
.i-amphtml-twitter-burst[i-amphtml-loading="done"] .i-amphtml-twitter-placeholder-svg {
transition-duration: 250ms;
transition-timing-function: ease-out;
transform: scale(12);
Expand Down
15 changes: 9 additions & 6 deletions extensions/amp-twitter/0.1/amp-twitter.js
Expand Up @@ -31,7 +31,7 @@ import {setStyle} from '../../../src/style';
* plusing.
*/
function isPulsingPlaceholder(win) {
return isExperimentOn(win, 'twitter-default-placeholder');
return isExperimentOn(win, 'twitter-default-placeholder-pulse');
}

/**
Expand All @@ -45,19 +45,19 @@ function isFadingPlaceholder(win) {

/**
* @param {!Window} win
* @return {boolean} True if we should show the default placeholder.
* @return {boolean} True if we should show the default placeholder with
* a burst ending animation.
*/
function isStaticPlaceholder(win) {
return isExperimentOn(win, 'twitter-default-placeholder-static');
function isBurstingPlaceholder(win) {
return isExperimentOn(win, 'twitter-default-placeholder-burst');
}

/**
* @param {!Window} win
* @return {boolean} True if we should show the default placeholder.
*/
function enableDefaultPlaceholder(win) {
return isPulsingPlaceholder(win) || isStaticPlaceholder(win) ||
isFadingPlaceholder(win);
return isExperimentOn(win, 'twitter-default-placeholder');
}

class AmpTwitter extends AMP.BaseElement {
Expand Down Expand Up @@ -135,6 +135,9 @@ class AmpTwitter extends AMP.BaseElement {
if (isFadingPlaceholder(this.win)) {
this.element.classList.add('i-amphtml-twitter-fade');
}
if (isBurstingPlaceholder(this.win)) {
this.element.classList.add('i-amphtml-twitter-burst');
}
this.updateForLoadingState_();
listenFor(iframe, MessageType.EMBED_SIZE, data => {
this.updateForSuccessState_(data['height']);
Expand Down

0 comments on commit 5798e1e

Please sign in to comment.