-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsaloon-doors.php
131 lines (110 loc) · 2.86 KB
/
saloon-doors.php
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
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Saloon Doors</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="util.js"></script>
<style>
.container1, .container2 {
width: 200px;
height: 260px;
position: relative;
border: 1px solid #CCC;
margin-bottom: 40px;
float: left;
-webkit-perspective: 800px;
}
.container1 {
margin-left: 160px;
}
#left-door, #right-door {
width: 100%;
height: 100%;
position: absolute;
-webkit-transition: -webkit-transform 1s;
-webkit-transform-style: preserve-3d;
}
#left-door {
-webkit-transform-origin: left center;
}
#right-door {
-webkit-transform-origin: right center;
}
#left-door.out {
-webkit-transform: rotateY( 180deg );
}
#right-door.out {
-webkit-transform: rotateY( -180deg );
}
#left-door.in {
-webkit-transform: rotateY( -180deg );
}
#right-door.in {
-webkit-transform: rotateY( 180deg );
}
#left-door figure, #right-door figure {
display: block;
height: 100%;
width: 100%;
line-height: 260px;
color: white;
text-align: center;
font-weight: bold;
font-size: 140px;
position: absolute;
-webkit-backface-visibility: hidden;
}
#left-door .front, #right-door .front {
background: red;
}
#left-door .back {
background: blue;
-webkit-transform: rotateY( 180deg );
}
#right-door .back {
background: blue;
-webkit-transform: rotateY( -180deg );
}
</style>
<script>
var init = function() {
var left = document.querySelector('#left-door'),
right = document.querySelector('#right-door');
document.querySelector('#out').addEventListener( 'click', function(){
left.style.webkitTransform = 'rotateY( 180deg )';
right.style.webkitTransform = 'rotateY( -180deg )';
}, false);
document.querySelector('#in').addEventListener( 'click', function(){
left.style.webkitTransform = 'rotateY( -180deg )';
right.style.webkitTransform = 'rotateY( 180deg )';
}, false);
document.querySelector('#close').addEventListener( 'click', function(){
left.style.webkitTransform = 'rotateY( 0deg )';
right.style.webkitTransform = 'rotateY( 0deg )';
}, false);
};
window.addEventListener('DOMContentLoaded', init, false);
</script>
</head>
<body>
<h1>Saloon Doors</h1>
<section class="container1">
<div id="left-door">
<figure class="front">1</figure>
<figure class="back">2</figure>
</div>
</section>
<section class="container2">
<div id="right-door">
<figure class="front">1</figure>
<figure class="back">2</figure>
</div>
</section>
<section id="options">
<p><button id="in">Coming In</button></p>
<p><button id="out">Going Out</button></p>
<p><button id="close">Close</button></p>
</section>
</body>
</html>