/
githubmirror
/
amphtml
Обзор
Документация
Войти
/
githubmirror
/
amphtml
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
examples/amp-action-macro.html
102 строки
4 KB
Caroline Liu
Apply lang="en" to examples/ (#34759)
10 июн 2021, 17:30
Не верифицирован
10 июн 2021, 17:30
2ee75c4
Код
Авторство
О чём код?
<!-- ## Introduction The [`amp-action-macro`](https://amp.dev/documentation/components/amp-action-macro) component allows for the reuse of action definitions. --> <!-- --> <!doctype html> <html ⚡ lang="en"> <head> <meta charset="utf-8"> <script async src="https://cdn.ampproject.org/v0.js"></script> <!-- ## Setup --> <!-- Import the `amp-action-macro` component ... --> <script async custom-element="amp-action-macro" src="https://cdn.ampproject.org/v0/amp-action-macro-0.1.js"></script> <!-- Import the `amp-carousel` component ... --> <script async custom-element="amp-carousel" src="https://cdn.ampproject.org/v0/amp-carousel-0.1.js"></script> --> <link rel="canonical" href="https://amp.dev/documentation/examples/components/amp-action-macro/"> <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> </head> <body> <amp-carousel id="scrollable-carousel" width="800" height="300" layout="fixed" type="carousel"> <amp-img src="https://picsum.photos/1600/900?image=110" width="400" height="225" aria-label="Aria labels are cool."></amp-img> <amp-img src="https://picsum.photos/1600/900?image=112" width="400" height="225"></amp-img> <amp-img src="https://picsum.photos/1600/900?image=113" width="400" height="225"></amp-img> <amp-img src="https://picsum.photos/1600/900?image=110" width="400" height="225" alt="a beautiful cat"></amp-img> <amp-img src="https://picsum.photos/1600/900?image=112" width="400" height="225"></amp-img> <amp-img src="https://picsum.photos/1600/900?image=113" width="400" height="225"></amp-img> </amp-carousel> <!-- An amp action macro. --> <amp-action-macro id="scrollable-carousel-macro" execute="scrollable-carousel.goToSlide(index=1)"> </amp-action-macro> <!-- An amp action macro with arguments --> <amp-action-macro id="scrollable-carousel-macro-args" execute="scrollable-carousel.goToSlide(index=x)" arguments="x"> </amp-action-macro> <!-- An amp action macro with multiple actions. --> <amp-action-macro id="scrollable-carousel-macro-multi" execute="scrollable-carousel.goToSlide(index=x), scrollable-carousel.goToSlide(index=y)" arguments="y,x"> </amp-action-macro> <!-- An amp action macro referencing an action macro that is defined after it. --> <amp-action-macro id="scrollable-carousel-macro-refers-an-action-macro-defined-after-it" execute="scrollable-carousel-macro-refers-an-action-macro.execute(x=2)" arguments="x"> </amp-action-macro> <!-- An amp action macro referencing another action macro. --> <amp-action-macro id="scrollable-carousel-macro-refers-an-action-macro" execute="scrollable-carousel-macro-args.execute(x=2)" arguments="x"> </amp-action-macro> <!-- Call to action-macro. --> <button on="tap:scrollable-carousel-macro.execute()">Go to slide 1</button> <!-- Different calls referencing the action macro, with different arguments. --> <button on="tap:scrollable-carousel-macro-args.execute(x=1)">Go to slide 1</button> <button on="tap:scrollable-carousel-macro-args.execute(x=2)">Go to slide 2</button> <br /> <!-- Invokes the multi action action macro --> <button on="tap:scrollable-carousel-macro-multi.execute(x=1,y=2)">Go to slide 1 then slide 2</button> <!-- Call to an action-macro that calls an action macro. --> <button on="tap:scrollable-carousel-macro-refers-an-action-macro.execute()">Go to slide 2</button> <!-- Invalid call action macro call. Action macro referenced --> <button on="tap:scrollable-carousel-macro-refers-an-action-macro-defined-after-it.execute()">Invalid call</button> </body> </html>