Skip to content

Commit 0a1ed60

Browse files
author
Raphael Brand
committed
add media queries and resize event handler
1 parent 42612ef commit 0a1ed60

File tree

3 files changed

+66
-12
lines changed

3 files changed

+66
-12
lines changed

demo/app/index.pug

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ html
99
script(type='text/javascript', data-main='js/main', src='js/vendor/require.min.js')
1010
body
1111
.container
12-
.jumbotron
13-
.heading1.animation Hello World!
1412
canvas#canvas(width=300,height=300)
1513
#perspective
1614
#perspective_stats

demo/app/js/acceleration.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ define('acceleration', () => {
4545
return el.classList.remove("active");
4646
});
4747
return true;
48-
}, 400) && document.querySelector('.' + code).classList.add("active");
48+
}, 400) && code && document.querySelector('.' + code).classList.add("active");
4949
setTimeout(function () {
50-
return document.querySelector('.' + code).blur();
50+
if(code)
51+
return document.querySelector('.' + code).blur();
5152
}, 400);
5253
};
5354

@@ -99,6 +100,21 @@ define('acceleration', () => {
99100
return hasMoved;
100101
};
101102

103+
let toggleView = false // window.innerWidth <= 414;
104+
let onWindowResize = (update) => {
105+
106+
if(update)
107+
toggleView = window.innerWidth <= 414;
108+
109+
if(toggleView)
110+
document.querySelector('.info.button').classList.add('active')
111+
else
112+
document.querySelector('.info.button').classList.remove('active')
113+
};
114+
115+
onWindowResize(false);
116+
117+
102118
var printMap = function printMap() {
103119
//var x, y;
104120
//x=0, y=0;
@@ -135,10 +151,12 @@ define('acceleration', () => {
135151
el.classList.remove("active"), el.blur();
136152
document.querySelector(".info.button").focus();
137153
document.querySelector(".overlay").classList.add("hidden");
154+
window.addEventListener('resize', onWindowResize);
138155
//document.querySelector('.info.button').innerHTML += '<br>' + printMap();
139156
}, 500, document.querySelector(".up"));
140157
document.querySelector(".info.button").addEventListener("click", function (e) {
141-
e.target.classList.add("active");
158+
toggleView = !toggleView
159+
onWindowResize(false)
142160
}, false);
143161
console.log("Legend:\n player is 2,\nfield free-to-go is 0,\nno-go is 1");
144162
//printMap();

demo/app/sass/acceleration.sass

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,21 @@
3030
cursor: pointer
3131

3232
.btnWrap
33+
top: 10px
3334
overflow: hidden
3435
display: inline
3536
position: absolute
3637
width: calc(50% - 10px)
3738
right: 10px
39+
min-width: 280px
40+
opacity: 1
41+
transition: all 1s
3842

3943
body
4044
overflow: hidden
4145
background-color: slategray
46+
padding: 7px
47+
transition: background-color 1s
4248

4349
.overlay
4450
position: absolute
@@ -71,23 +77,55 @@ body
7177
div.info.button
7278
font-family: 'Courier'
7379
cursor: pointer
74-
padding: 20px
75-
width: 100%
76-
padding: 2px
77-
height: 20px
7880
display: block
81+
//margin: 3px
82+
margin-top: 12px
83+
//padding: 5px
84+
height: 45px
7985
font-size: 1.1em
8086
font-stretch: 1.1em
8187
background-color: lightgray
82-
padding-right: 0%
88+
padding: 10px
8389
overflow: hidden
8490
line-height: 1.4em
8591
transition: all 1s
8692
color: #000
87-
93+
94+
.innerText
95+
padding: 0
96+
opacity: 0
97+
transition: padding 2s, opacity 1s
98+
8899
&.active
89100
height: 300px
90-
padding-right: 40%
91101
overflow-y: yes
92102
text-decoration: none
103+
104+
.innerText
105+
padding: 3px
106+
opacity: 1
107+
108+
109+
@media screen and(max-width:414px)
110+
body
111+
background-color: #338
112+
.btnWrap
113+
opacity: 0.5
114+
position: absolute
115+
top: 40px
116+
117+
div.info.button
118+
min-width: 279px
119+
height: 72px
120+
div.info.button.active
121+
color: transparent
122+
height: 282px
123+
.innerText
124+
padding: 3px
125+
color: black
126+
position: relative
127+
//overflow: visible
128+
bottom: 62px
129+
clear: both
130+
93131

0 commit comments

Comments
 (0)