Skip to content

Commit f6b0da5

Browse files
added automatic resize of elements
1 parent ea052bc commit f6b0da5

File tree

2 files changed

+62
-44
lines changed

2 files changed

+62
-44
lines changed

css/main.css

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ html, body {
88
padding: 0;
99
width: 100%;
1010
height: 100%;
11+
overflow: hidden;
1112
}
1213

1314
#loading {
@@ -22,8 +23,9 @@ header {
2223
padding: 0;
2324
margin: 0;
2425
height: 50px;
25-
min-height: 50px;
26-
max-height: 50px;
26+
min-height: 55px;
27+
max-height: 55px;
28+
line-height: normal;
2729
border-bottom: 5px solid #33b5e5;
2830
box-shadow: 0px 3px 3px #888;
2931
z-index: 5;
@@ -110,14 +112,20 @@ header > div,
110112
opacity: 0.6;
111113
}
112114

113-
114-
@media only screen and (max-height: 480px) {
115-
.landscape { display: none; }
116-
#map{
117-
height: 225px;
115+
@media only screen and (min-width: 321px) {
116+
.portrait { display: none; }
117+
.landscape { display: block; }
118+
#map {
119+
float: right;
120+
height: 245px;
121+
width: 280px;
118122
}
119123
#main {
120-
height: 180px;
124+
float: left;
125+
height: 245px;
126+
width: 199px;
127+
border-right: 1px solid #ddd;
128+
overflow: hidden;
121129
}
122130
#main .header {
123131
height: 20px;
@@ -126,23 +134,18 @@ header > div,
126134
}
127135
#main .data {
128136
background-color: #f4f4f4;
129-
height: 140px;
137+
height: 100%;
138+
padding-bottom: 10px;
130139
}
131140
#main .data .left {
132141
float: left;
133-
width: 65%;
142+
width: 160px;
134143
padding-left: 10px;
135-
padding-right: 20px;
136-
}
137-
#main .data .right {
138-
float: right;
139-
padding-right: 10px;
140-
width: 20%;
141144
}
142145
#main .data dl > dt {
143146
color: #000;
144147
line-height: 11px;
145-
margin-top: 15px;
148+
margin-top: 10px;
146149
font-weight: bold;
147150
font-size: 14px;
148151
}
@@ -160,22 +163,19 @@ header > div,
160163
#main .data dl > dd.recievers {
161164
font-size: 10px;
162165
}
166+
#main .row .data img {
167+
right: 5%;
168+
top: 50px;
169+
}
163170
}
164-
@media only screen and (max-height: 320px) {
165-
.portrait { display: none; }
166-
.landscape { display: block; }
167-
.container { width: 460px; }
168-
#map {
169-
float: right;
170-
height: 245px;
171-
width: 280px;
171+
@media only screen and (max-width: 320px) {
172+
.portrait { display: block; }
173+
.landscape { display: none; }
174+
#map{
175+
height: 225px;
172176
}
173177
#main {
174-
float: left;
175-
height: 245px;
176-
width: 199px;
177-
border-right: 1px solid #ddd;
178-
overflow: hidden;
178+
height: 180px;
179179
}
180180
#main .header {
181181
height: 20px;
@@ -184,18 +184,23 @@ header > div,
184184
}
185185
#main .data {
186186
background-color: #f4f4f4;
187-
height: 100%;
188-
padding-bottom: 10px;
187+
height: 140px;
189188
}
190189
#main .data .left {
191190
float: left;
192-
width: 160px;
191+
width: 65%;
193192
padding-left: 10px;
193+
padding-right: 20px;
194+
}
195+
#main .data .right {
196+
float: right;
197+
padding-right: 10px;
198+
width: 20%;
194199
}
195200
#main .data dl > dt {
196201
color: #000;
197202
line-height: 11px;
198-
margin-top: 10px;
203+
margin-top: 15px;
199204
font-weight: bold;
200205
font-size: 14px;
201206
}
@@ -213,8 +218,4 @@ header > div,
213218
#main .data dl > dd.recievers {
214219
font-size: 10px;
215220
}
216-
#main .row .data img {
217-
right: 5%;
218-
top: 50px;
219-
}
220221
}

js/app.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,34 @@ var preloadImages = [
77
"img/menu-icons.png",
88
];
99

10-
function hideAddressbar()
11-
{
12-
window.scrollTo(0, 1);
13-
}
10+
function checkSize() {
11+
// we are in landscape mode
12+
w = $(window).width();
13+
h = $(window).height();
14+
hh = $('header').height();
15+
sw = $('#main').width();
16+
17+
if($('.landscape:visible').length) {
18+
$('.container').width(w-40);
19+
$('#main,#map').height(h-hh-5);
20+
$('#map').width(w-sw-1);
21+
} else { // portrait mode
22+
$('.container').width(w-20);
23+
$('#main,#map').height(h-hh-5-180);
24+
$('#map').width(w);
25+
}
1426

15-
function checkPreload() {
27+
if(map) map.checkResize();
1628
}
1729

30+
window.onresize = checkSize;
31+
1832

1933
$(window).ready(function() {
20-
window.onorientationchange = hideAddressbar();
34+
// resize elements if needed
35+
checkSize();
36+
37+
// add inline scroll to vehicle list
2138
listScroll = new iScroll('main', { hScrollbar: false, snap: true });
2239

2340
// click first icon for popup with the window size

0 commit comments

Comments
 (0)