-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add amp-fx="fade-in" - scroll triggered timed animation. (#14351)
* WIP * Refactor parallax code to make it easier to add new presets * Force Travis checks * Travis fixes * Private -> protected * Add support for amp-fx='fade-in'. Write example and validator tests accordingly as well * Demos post UX review * Add 'real world' example that uses amp-fx='fade-in' * Commit worthy test * Add support for easing keywords * Only access private members through accessors * Only access private members through accessors * Remove demo files * Add accessor for resources. * Fix linter errors * Formatting FUNS * Fix markdown * Moar demos * Gate amp-fx='fade-in' experiment * Edits before push * markdown changes * Bring back demos * remove US demos * Respond to alanorozco@'s comments * Fix build failures * Fix missing support check * Travis fixes * Cleanups * Remove references to fade-in * Don't use private members outside class * OOPS
- Loading branch information
Showing
10 changed files
with
315 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<!doctype html> | ||
<html ⚡> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>AMP Article with fade-in animations</title> | ||
<link rel="canonical" href="amps.html"> | ||
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"> | ||
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript> | ||
<script async src="https://cdn.ampproject.org/v0.js"></script> | ||
<script async custom-element="amp-fx-collection" src="https://cdn.ampproject.org/v0/amp-fx-collection-0.1.js"></script> | ||
<style amp-custom> | ||
.spacer { | ||
margin-top: 10px; | ||
height: 70vh; | ||
width: 100%; | ||
background-image: -webkit-linear-gradient(#EEE 50%, white 50%); | ||
background-image: linear-gradient(#EEE 50%, white 50%); | ||
background-size: 100% 3em; | ||
} | ||
|
||
header { | ||
position: relative; | ||
} | ||
|
||
h1 { | ||
margin: 0px 10px; | ||
} | ||
|
||
header h1 { | ||
position: absolute; | ||
top: 20vh; | ||
padding: 5px; | ||
z-index: 1; | ||
} | ||
|
||
header h1 span, .title { | ||
background-color: black; | ||
color: white; | ||
line-height: 1.2em; | ||
} | ||
|
||
amp-img img { | ||
object-fit: cover; | ||
} | ||
|
||
.overlay-top { | ||
position: absolute; | ||
top: 0; | ||
} | ||
|
||
.overlay-container { | ||
position: relative; | ||
overflow: hidden; | ||
} | ||
|
||
main { | ||
font-family: Helvetica, sans-serif; | ||
padding: 10px; | ||
max-width: 412px; | ||
margin: auto; | ||
} | ||
|
||
a, a:visited, a:active { | ||
color: #2196F3; | ||
text-decoration: none; | ||
display: block; | ||
padding: 5px; | ||
} | ||
|
||
.overflow-window { | ||
overflow: hidden; | ||
} | ||
|
||
.overflow-window amp-img { | ||
margin-bottom: -80%; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<main> | ||
<header> | ||
<h1> | ||
<span class="title">Lorem Ipsum Dolor Sit Lorem Ipsum<span> | ||
</h1> | ||
<amp-img height="50vh" layout="fixed-height" src="https://picsum.photos/1600/900?image=1069"></amp-img> | ||
</header> | ||
|
||
<article> | ||
<div class="spacer"></div> | ||
<div class="overlay-container"> | ||
<amp-img layout=responsive width=1600 height=900 src="https://picsum.photos/1600/900?image=981"></amp-img> | ||
<h1 class="overlay-top" amp-fx="fade-in"> | ||
<span class="title">Default easing, margin and duration<span> | ||
</h1> | ||
</div> | ||
<div class="spacer"></div> | ||
<div class="overflow-window"> | ||
<amp-img amp-fx="fade-in" data-duration="200ms" layout=responsive width=900 height=1600 src="https://picsum.photos/900/1600?image=736"></amp-img> | ||
</div> | ||
<div class="spacer"></div> | ||
<div class="overflow-window"> | ||
<amp-img amp-fx="fade-in" data-margin="0.5" layout=responsive width=900 height=1600 src="https://picsum.photos/900/1600?image=736"></amp-img> | ||
</div> | ||
<div class="spacer"></div> | ||
<div class="overflow-window"> | ||
<amp-img amp-fx="fade-in" data-easing="ease-out" layout=responsive width=900 height=1600 src="https://picsum.photos/900/1600?image=736"></amp-img> | ||
</div> | ||
</article> | ||
</main> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
extensions/amp-fx-collection/0.1/providers/amp-fx-presets-utils.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright 2018 The AMP HTML Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS-IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* @fileoverview Common animations utility functions used in the amp-fx | ||
* presets. | ||
*/ | ||
|
||
import {startsWith} from '../../../../src/string'; | ||
import {user} from '../../../../src/log'; | ||
|
||
/** | ||
* Converts the data-fade-ineasing input into the corresponding `cubic-bezier()` | ||
* notation. | ||
* @param {string} keyword to be converted. | ||
* @return {string} cubic-bezier() notation. | ||
*/ | ||
export function convertEasingKeyword(keyword) { | ||
switch (keyword) { | ||
case 'linear': | ||
return 'cubic-bezier(0.00, 0.00, 1.00, 1.00)'; | ||
case 'ease-in-out': | ||
return 'cubic-bezier(0.80, 0.00, 0.20, 1.00)'; | ||
case 'ease-in': | ||
return 'cubic-bezier(0.80, 0.00, 0.60, 1.00)'; | ||
case 'ease-out': | ||
return 'cubic-bezier(0.40, 0.00, 0.40, 1.00)'; | ||
default: | ||
user().assert(startsWith(keyword, 'cubic-bezier'), | ||
'All custom bezier curves should be specified by following the ' + | ||
'`cubic-bezier()` function notation.'); | ||
return keyword; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.