Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ Require trigger="visibility" to run an <amp-story-animation> effect #28257

Merged
merged 6 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/amp-story/amp-story-animation.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
fly-in with animate-in, after the previous element
</div>
</amp-story-grid-layer>
<amp-story-animation layout="nodisplay">
alanorozco marked this conversation as resolved.
Show resolved Hide resolved
<amp-story-animation layout="nodisplay" trigger="in">
<script type="application/json">
{
"selector": ".animate",
Expand All @@ -59,7 +59,7 @@
fly-in with animate-in, after the previous element
</div>
</amp-story-grid-layer>
<amp-story-animation layout="nodisplay">
<amp-story-animation layout="nodisplay" trigger="in">
<script type="application/json">
{
"selector": ".animate",
Expand All @@ -80,7 +80,7 @@
<div class="box animate-bottom"></div>
<div class="box animate-right"></div>
</amp-story-grid-layer>
<amp-story-animation layout="nodisplay">
<amp-story-animation layout="nodisplay" trigger="in">
<script type="application/json">
[
{
Expand Down
8 changes: 2 additions & 6 deletions extensions/amp-story/1.0/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,11 @@ import {
WebKeyframesDef,
} from './animation-types';
import {assertDoesNotContainDisplay, setStyles} from '../../../src/style';
import {
childElementsByTag,
scopedQuerySelector,
scopedQuerySelectorAll,
} from '../../../src/dom';
import {dev, devAssert, user, userAssert} from '../../../src/log';
import {escapeCssSelectorIdent} from '../../../src/css';
import {getChildJsonConfig} from '../../../src/json';
import {map, omit} from '../../../src/utils/object';
import {scopedQuerySelector, scopedQuerySelectorAll} from '../../../src/dom';
import {timeStrToMillis, unscaledClientRect} from './utils';

/** @const {string} */
Expand Down Expand Up @@ -638,7 +634,7 @@ export class AnimationManager {
)
.concat(
Array.prototype.map.call(
childElementsByTag(this.page_, 'amp-story-animation'),
this.page_.querySelectorAll('amp-story-animation[trigger=in]'),
(el) =>
this.createRunner_({
source: el,
Expand Down
5 changes: 3 additions & 2 deletions extensions/amp-story/1.0/test/test-animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,10 @@ describes.realWin('amp-story animations', {}, (env) => {

const page = html`
<div>
<amp-story-animation ref="spec1source">
<amp-story-animation trigger="in" ref="spec1source">
<script type="application/json"></script>
</amp-story-animation>
<amp-story-animation ref="spec2source">
<amp-story-animation trigger="in" ref="spec2source">
<script type="application/json"></script>
</amp-story-animation>
</div>
Expand Down Expand Up @@ -647,6 +647,7 @@ describes.realWin('amp-story animations', {}, (env) => {
id="animated-fourth"
ref="animatedFourth"
animate-in-after="animated-third"
trigger="in"
>
<script type="application/json">
{}
Expand Down