1 | dynamicResize = function(bound) { |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
2 | |||
3 | var monitor_width, monitor_height, |
||
4 | margin_x, margin_y, |
||
5 | padding_x, padding_y, |
||
6 | canvas_width, canvas_height, |
||
7 | body_width = $('body').width(), |
||
8 | body_height = $('body').height(); |
||
9 | |||
10 | if ((body_width / body_height) < 1.4) { |
||
11 | monitor_width = body_width; |
||
12 | monitor_height = Math.floor(monitor_width * 789 / 1104); |
||
13 | margin_x = 0; |
||
14 | margin_y = Math.floor((body_height - monitor_height) / 2); |
||
15 | } else { |
||
16 | monitor_height = body_height; |
||
17 | monitor_width = Math.floor(monitor_height * 1104 / 789); |
||
18 | margin_x = Math.floor((body_width - monitor_width) / 2); |
||
19 | margin_y = 0; |
||
20 | } |
||
21 | |||
22 | $('#monitor').show().width(monitor_width).height(monitor_height) |
||
23 | .css('margin', margin_y + 'px ' + margin_x + 'px'); |
||
24 | |||
25 | padding_x = Math.floor(120 * monitor_width / 1104); |
||
26 | padding_y = Math.floor(106 * monitor_height / 789); |
||
27 | canvas_width = monitor_width - (2 * padding_x); |
||
28 | canvas_height = monitor_height - (2 * padding_y); |
||
29 | |||
30 | $('#main').width(canvas_width).height(canvas_height) |
||
31 | .css('margin', (margin_y + padding_y) + 'px ' + (margin_x + padding_x) + 'px'); |
||
32 | |||
33 | padding_x = Math.floor(24 * monitor_width / 1104); |
||
34 | padding_y = Math.floor(24 * monitor_height / 789); |
||
35 | canvas_width -= 2 * Math.floor(padding_x ); |
||
36 | canvas_height -= 2 * Math.floor(padding_y ); |
||
37 | |||
38 | $('#main canvas').width(canvas_width).height(canvas_height) |
||
39 | .css('margin', padding_y + 'px ' + padding_x + 'px'); |
||
40 | |||
41 | } |
||
42 | |||
43 | // When all assets such as images have been completely received, runs the demo |
||
44 | $(window).load(function() { |
||
45 | init(); |
||
46 | dynamicResize(true); |
||
47 | }); |
||
48 | |||
49 | // When document is ready |
||
50 | $(document).ready(function() { |
||
51 | $(window).resize(function(){ |
||
52 | dynamicResize(true); |
||
53 | }); |
||
54 | }); |
||
55 |