-
Notifications
You must be signed in to change notification settings - Fork 112
/
index.html
258 lines (234 loc) · 8.33 KB
/
index.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><x-gif></title>
<script>
if ('registerElement' in document
&& 'createShadowRoot' in HTMLElement.prototype
&& 'import' in document.createElement('link')
&& 'content' in document.createElement('template')) {
// We're using a browser with native WC support!
} else {
document.write('<script src="https:\/\/cdnjs.cloudflare.com/ajax/libs/polymer/0.3.4/platform.js"><\/script>')
}
</script>
<script src="demos/angular.min.js"></script>
<link rel="import" href="dist/x-gif.html">
<link rel="stylesheet" href="demos/foundation.min.css"/>
<style>
body {
margin: 0;
background-color: #f9f9f9;
height: 100%;
text-align: center;
padding-bottom: 24px;
}
h3 {
margin-top: 2em;
}
body[unresolved] {
opacity: 0;
}
pre {
font-weight: bold;
margin-top: 8px;
}
.me {
height: 72px;
width: 72px;
border-radius: 50%;
box-shadow: 0 0 0 2px white, 0 0 0 3px black;
margin: 16px;
}
footer {
margin-bottom: 30px;
}
figcaption {
margin-bottom: 2em;
}
</style>
</head>
<body ng-app="x-gif-demo" ng-controller="DemoCtrl">
<div class="row">
<div class="column medium-9 medium-centered large-8">
<header>
<h1><x-gif></h1>
<h4>The GIF tag the internet deserves</h4>
<h6><a href="https://github.com/geelen/x-gif" target="_blank">View source on GitHub</a></h6>
</header>
<hr/>
<dl class="sub-nav">
<dt>Examples:</dt>
<dd ng-repeat="url in gifs" ng-class="{active: gif.url == url}"><a ng-href="#{{ url }}"> {{ $index + 1 }} </a>
</dd>
</dl>
<label>
Or choose your own. Be sure to choose a server with permissive CORS headers, e.g. imgur
<input type="text" ng-model="gif.url"/>
</label>
<h3>Normal playback</h3>
<p class="small">Something not look right? <a href="https://github.com/geelen/x-gif/issues" target="_blank">Post an
issue on GitHub</a> with the URL of the image</p>
<figure>
<x-gif ng-src="{{ trustedUrl() }}"></x-gif>
<figcaption>
<pre><x-gif src="{{ trustedUrl() }}"></x-gif></pre>
</figcaption>
</figure>
<h3>Ping-pong</h3>
<figure>
<x-gif ng-src="{{ trustedUrl() }}" ping-pong></x-gif>
<figcaption>
<pre><x-gif src="{{ trustedUrl() }}" ping-pong></x-gif></pre>
</figcaption>
</figure>
<h3>N-times</h3>
<button ng-click="nTimesRestart()" type="button" class="button tiny radius" style="padding: 0.8em;">Restart</button>
<input type="range" min="0.1" max="3.0" step="0.1" ng-model="gif.nTimes"/> {{ gif.nTimes }}
<figure>
<x-gif id="nTimes" ng-src="{{ trustedUrl() }}" n-times="{{ gif.nTimes }}"></x-gif>
<figcaption>
<pre><x-gif src="{{ trustedUrl() }}" n-times="{{ gif.nTimes }}"{{ nTimesIsStopped() }}></x-gif></pre>
</figcaption>
</figure>
<h3>Speed</h3>
<figure>
<label>
<input type="range" min="0.1" max="5" step="0.1" ng-model="gif.speed"/> {{ gif.speed }}
</label>
<x-gif ng-src="{{ trustedUrl() }}" speed="{{ gif.speed }}"></x-gif>
<figcaption>
<pre><x-gif src="{{ trustedUrl() }}" speed="{{ gif.speed }}"></x-gif></pre>
</figcaption>
</figure>
<h3>BPM</h3>
<figure>
<label>
<input type="range" min="30" max="240" step="1" ng-model="gif.bpm"/> {{ gif.bpm }}
</label>
<x-gif ng-src="{{ trustedUrl() }}" bpm="{{ gif.bpm }}"></x-gif>
<figcaption>
<pre><x-gif src="{{ trustedUrl() }}" bpm="{{ gif.bpm }}"></x-gif></pre>
</figcaption>
<x-gif ng-src="{{ trustedUrl() }}" bpm="{{ gif.bpm }}" snap></x-gif>
<figcaption>
<pre><x-gif src="{{ trustedUrl() }}" bpm="{{ gif.bpm }}" snap></x-gif></pre>
</figcaption>
</figure>
<h3>Synced to Audio</h3>
<figure>
<div ng-show="gif.metadata">
<audio controls preload>
<source src="demos/cc_audio/encom_part_ii.ogg" type="audio/ogg">
<source src="demos/cc_audio/encom_part_ii.mp3" type="audio/mpeg">
</audio>
<p>Playback speed: {{ gif.playbackRate | number:1 }} <a href ng-click="changeSpeed(0.1)">+</a> <a href
ng-click="changeSpeed(-0.1)">-</a>
</p>
</div>
<div ng-hide="gif.metadata">Loading beat data...</div>
<x-gif class="x-gif-synced-demo" ng-src="{{ trustedUrl() }}" sync></x-gif>
<figcaption>
<pre><x-gif src="{{ trustedUrl() }}" synced></x-gif></pre>
</figcaption>
<x-gif class="x-gif-synced-demo" ng-src="{{ trustedUrl() }}" sync snap></x-gif>
<figcaption>
<pre><x-gif src="{{ trustedUrl() }}" synced snap></x-gif></pre>
<p>
Audio: Encom Part II by Daft Punk. CC0 1.0 Universal.
<br/>
Source:
<a href="https://archive.org/details/DaftPunkTronLegacyEncomPartIi" target="_blank">Archive.org</a>
<br/>
Beat metadata provided by <a href="http://echonest.com/">Echo Nest</a>
</p>
<h5><a href="demos/audio.html">See a full screen demo</a></h5>
</figcaption>
</figure>
<h3>Stop-start</h3>
<pre><x-gif src="{{ trustedUrl() }}" stopped></x-gif></pre>
<h5><a href="demos/stoppable.html">See demo</a></h5>
<h3>Exploded</h3>
<pre><x-gif src="{{ trustedUrl() }}" exploded></x-gif></pre>
<p>Explode the gif into its component frames (handy for debugging)</p>
<h5><a href="demos/exploded.html">See demo</a></h5>
<hr/>
<footer>
<h5>Made with <3 by</h5>
<img class="me" src="http://i.imgur.com/x577Tga.jpg" alt=""/>
<br/>
<a target="_blank" href="https://twitter.com/glenmaddern">@glenmaddern</a>
</footer>
</div>
</div>
<script src="demos/synched_playback.js"></script>
<script type="text/javascript" charset="utf-8">
angular.module('x-gif-demo', [])
.controller('DemoCtrl', function ($scope, $sce, $location, $http) {
$scope.gifs = [
"http://i.imgur.com/iKXH4E2.gif",
"http://i.imgur.com/RY2vTBQ.gif",
"http://i.imgur.com/YlxOOI7.gif",
"http://i.imgur.com/5KSc0px.gif",
"http://i.imgur.com/m25uYzq.gif",
"http://i.imgur.com/ifR7csn.gif"
];
$scope.gif = {
url: $scope.gifs[0],
speed: 2,
bpm: 60,
playbackRate: 1,
nTimes: 1.0
};
var audio = document.querySelector('audio');
$scope.changeSpeed = function (delta) {
audio.playbackRate = Math.max(0.5, audio.playbackRate + delta);
$scope.gif.playbackRate = audio.playbackRate;
}
var nTimesElem = document.querySelector('#nTimes');
$scope.nTimesRestart = function () {
nTimesElem.removeAttribute('stopped');
}
$scope.nTimesIsStopped = function () {
return nTimesElem.hasAttribute('stopped') ? " stopped" : "";
}
nTimesElem.addEventListener('x-gif-finished', function () {
$scope.$apply();
})
$http.get('demos/cc_audio/encom_part_ii.json').then(function (response) {
$scope.gif.metadata = response.data;
setupAudioSynching(audio,
document.querySelectorAll('.x-gif-synced-demo'),
$scope.gif.metadata)
})
$scope.trustedUrl = function () {
return $sce.trustAsResourceUrl($scope.gif.url);
}
$scope.loc = $location;
$scope.$watch('loc.path()', function (e) {
if (e) $scope.gif.url = e.slice(1);
})
$scope.$watch('gif.url', function (e) {
if (e) $scope.loc.path(e);
})
});
</script>
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-32408977-5', 'geelen.github.io');
ga('send', 'pageview');
</script>
</body>
</html>