-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.js
33 lines (32 loc) · 1.31 KB
/
demo.js
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
function toggle() {
var card = document.getElementsByTagName('section')[0];
var button = document.getElementsByTagName('button')[0];
// Capture a snapshot of the card beforehand
var snapshot = Transition.snapshot(card);
// Expand/collapse the card
if (card.className === '') {
card.className = 'expanded';
button.textContent = 'Collapse';
} else {
card.className = '';
button.textContent = 'Expand';
}
// Animate the change
Transition.from(card, snapshot, 500);
}
function fab() {
var section = document.createElement('section');
section.className = 'expanded';
section.innerHTML = "<header>Card</header>" +
"<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod" +
"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam," +
"quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo" +
"consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse" +
"cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non" +
"proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>"/* +
"<button onclick='toggle()'>Expand</button>"*/;
var fab = document.getElementById('fab');
document.body.insertBefore(section, fab);
Transition.from(section,
Transition.snapshot(fab, ['border-radius']), 1000);
}