-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfsm.js
More file actions
80 lines (68 loc) · 2.24 KB
/
fsm.js
File metadata and controls
80 lines (68 loc) · 2.24 KB
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
//Setup
var fsmActual = document.createElement('div');
fsmActual.setAttribute('id', 'fsm_actual');
document.body.appendChild(fsmActual);
var $fsm = document.querySelectorAll('.fsm');;
var $fsmActual = document.querySelector('#fsm_actual');
$fsmActual.style.position = "absolute";
var position = {};
var size = {};
//modal action stuffs
var openFSM = function(event) {
var $this = event.currentTarget;
var clientRect = $this.getBoundingClientRect();
position = {
top: $this.getBoundingClientRect().top - document.body.getBoundingClientRect().top,
left: clientRect.left
}
size = {
width: window.getComputedStyle($this).width,
height: window.getComputedStyle($this).height
}
$fsmActual.style.position = "absolute";
$fsmActual.style.top = position.top + 'px';
$fsmActual.style.left = position.left + 'px';
$fsmActual.style.height = size.height;
$fsmActual.style.width = size.width;
$fsmActual.style.margin = $this.style.margin;
document.body.classList.add('no-scroll');
setTimeout(function(){
$fsmActual.innerHTML = $this.innerHTML;
var classes = $this.classList.value.split(' ');
for (var i = 0; i < classes.length; i++) {
$fsmActual.classList.add(classes[i]);
}
$fsmActual.classList.add('growing');
$fsmActual.style.height = '100vh';
$fsmActual.style.width = '100vw';
$fsmActual.style.top = window.pageYOffset + 'px';
$fsmActual.style.left = '0';
$fsmActual.style.margin = '0';
}, 1);
setTimeout(function(){
$fsmActual.classList.remove('growing');
$fsmActual.classList.add('full-screen')
}, 1000);
};
var closeFSM = function(event){
var $this = event.currentTarget;
$this.style.height = size.height;
$this.style.width = size.width;
$this.style.top = position.top + 'px';
$this.style.left = position.left + 'px';
$this.style.margin = '0';
$this.classList.remove('full-screen');
$this.classList.add('shrinking');
setTimeout(function(){
while($this.firstChild) $this.removeChild($this.firstChild);
var classList = $this.classList;
while (classList.length > 0) {
classList.remove(classList.item(0));
}
$this.style = '';;
}, 1000);
};
for (var i = 0; i < $fsm.length; i++) {
$fsm[i].addEventListener("click", openFSM);
}
$fsmActual.addEventListener("click", closeFSM);