forked from googlearchive/core-transition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
87 lines (70 loc) · 2.15 KB
/
demo.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
<!doctype html>
<!--
Copyright 2013 The Polymer Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>core-transition</title>
<script src="../platform/platform.js"></script>
<link href="core-transition-css.html" rel="import">
<style>
#animate-me {
background-color: lime;
position: fixed;
top: 100px;
width: 100%;
height: 100%;
}
</style>
</head>
<body unresolved>
<div id="animate-me" hidden></div>
<select id="sel" onchange="setup();">
<option value="core-transition-fade" selected>core-transition-fade</option>
<option value="core-transition-center">core-transition-center</option>
<option value="core-transition-top">core-transition-top</option>
<option value="core-transition-bottom">core-transition-bottom</option>
<option value="core-transition-left">core-transition-left</option>
<option value="core-transition-right">core-transition-right</option>
</select>
<button onclick="stuff();">toggle</button>
<script>
document.addEventListener('polymer-ready', function() {
// initial setup
setup();
document.getElementById('animate-me').removeAttribute('hidden');
});
var meta;
var transition;
var state = {
opened: false
}
function getMeta() {
if (!meta) {
meta = document.createElement('core-meta');
meta.type = 'transition';
}
return meta;
}
function setup() {
var target = document.getElementById('animate-me');
if (transition) {
transition.teardown(target);
}
var value = document.getElementById('sel').selectedOptions[0].value;
transition = getMeta().byId(value);
transition.setup(target);
}
function stuff() {
var target = document.getElementById('animate-me');
state.opened = !state.opened;
transition.go(target, state);
}
</script>
</body>
</html>