forked from ampproject/amphtml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcarousels.amp.html
89 lines (84 loc) · 5.86 KB
/
carousels.amp.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!doctype html>
<html ⚡>
<head>
<meta charset="utf-8">
<title>amp-bind: Carousels</title>
<link rel="canonical" href="amps.html">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Questrial" rel="stylesheet" type="text/css">
<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-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<script async custom-element="amp-carousel" src="https://cdn.ampproject.org/v0/amp-carousel-0.1.js"></script>
<script async custom-element="amp-selector" src="https://cdn.ampproject.org/v0/amp-selector-0.1.js"></script>
<style amp-custom>
amp-carousel .selected {
border: solid 2px red;
}
amp-img[selected] {
border: solid 2px green;
}
button {
border: solid 1px black;
}
</style>
</head>
<body>
<div>
<h2>Linked carousels</h2>
<p [text]="'Selected slide: ' + selectedSlide">Selected slide: None<p>
<amp-carousel controls type=slides width=400 height=300
[slide]="selectedSlide" on="slideChange:AMP.setState({selectedSlide: event.index})">
<amp-img src="https://ampbyexample.com/img/image1.jpg" width=400 height=300></amp-img>
<amp-img src="https://ampbyexample.com/img/image2.jpg" width=400 height=300></amp-img>
<amp-img src="https://ampbyexample.com/img/image3.jpg" width=400 height=300></amp-img>
<amp-img src="https://ampbyexample.com/img/image1.jpg" width=400 height=300></amp-img>
<amp-img src="https://ampbyexample.com/img/image2.jpg" width=400 height=300></amp-img>
<amp-img src="https://ampbyexample.com/img/image3.jpg" width=400 height=300></amp-img>
<amp-img src="https://ampbyexample.com/img/image1.jpg" width=400 height=300></amp-img>
<amp-img src="https://ampbyexample.com/img/image2.jpg" width=400 height=300></amp-img>
<amp-img src="https://ampbyexample.com/img/image3.jpg" width=400 height=300></amp-img>
</amp-carousel>
</div>
<p>Without <amp-selector></p>
<amp-carousel controls width=400 height=100>
<amp-img src="https://ampbyexample.com/img/image1.jpg" width=100 height=75
[class]="selectedSlide == 0 ? 'selected' : ''" on="tap:AMP.setState({selectedSlide: 0})"></amp-img>
<amp-img src="https://ampbyexample.com/img/image2.jpg" width=100 height=75
[class]="selectedSlide == 1 ? 'selected' : ''" on="tap:AMP.setState({selectedSlide: 1})"></amp-img>
<amp-img src="https://ampbyexample.com/img/image3.jpg" width=100 height=75
[class]="selectedSlide == 2 ? 'selected' : ''" on="tap:AMP.setState({selectedSlide: 2})"></amp-img>
<amp-img src="https://ampbyexample.com/img/image1.jpg" width=100 height=75
[class]="selectedSlide == 3 ? 'selected' : ''" on="tap:AMP.setState({selectedSlide: 3})"></amp-img>
<amp-img src="https://ampbyexample.com/img/image2.jpg" width=100 height=75
[class]="selectedSlide == 4 ? 'selected' : ''" on="tap:AMP.setState({selectedSlide: 4})"></amp-img>
<amp-img src="https://ampbyexample.com/img/image3.jpg" width=100 height=75
[class]="selectedSlide == 5 ? 'selected' : ''" on="tap:AMP.setState({selectedSlide: 5})"></amp-img>
<amp-img src="https://ampbyexample.com/img/image1.jpg" width=100 height=75
[class]="selectedSlide == 6 ? 'selected' : ''" on="tap:AMP.setState({selectedSlide: 6})"></amp-img>
<amp-img src="https://ampbyexample.com/img/image2.jpg" width=100 height=75
[class]="selectedSlide == 7 ? 'selected' : ''" on="tap:AMP.setState({selectedSlide: 7})"></amp-img>
<amp-img src="https://ampbyexample.com/img/image3.jpg" width=100 height=75
[class]="selectedSlide == 8 ? 'selected' : ''" on="tap:AMP.setState({selectedSlide: 8})"></amp-img>
</amp-carousel>
<p>
With <amp-selector>
<button on="tap:AMP.setState({selectorDisabled: !selectorDisabled})">Toggle selector[disabled]</button>
</p>
<amp-selector layout=container name="carousel-selector" [selected]="selectedSlide"
on="select:AMP.setState({selectedSlide: event.targetOption})"
[disabled]="selectorDisabled">
<amp-carousel controls width=400 height=100>
<amp-img src="https://ampbyexample.com/img/image1.jpg" width=100 height=75 option=0></amp-img>
<amp-img src="https://ampbyexample.com/img/image2.jpg" width=100 height=75 option=1></amp-img>
<amp-img src="https://ampbyexample.com/img/image3.jpg" width=100 height=75 option=2></amp-img>
<amp-img src="https://ampbyexample.com/img/image1.jpg" width=100 height=75 option=3></amp-img>
<amp-img src="https://ampbyexample.com/img/image2.jpg" width=100 height=75 option=4></amp-img>
<amp-img src="https://ampbyexample.com/img/image3.jpg" width=100 height=75 option=5></amp-img>
<amp-img src="https://ampbyexample.com/img/image1.jpg" width=100 height=75 option=6></amp-img>
<amp-img src="https://ampbyexample.com/img/image2.jpg" width=100 height=75 option=7></amp-img>
<amp-img src="https://ampbyexample.com/img/image3.jpg" width=100 height=75 option=8></amp-img>
</amp-carousel>
</amp-selector>
</body>
</html>