-
Notifications
You must be signed in to change notification settings - Fork 2
/
LayoutManager.js
31 lines (26 loc) · 950 Bytes
/
LayoutManager.js
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
function AdaptiveLayoutManager(originalWidth,originalHeight,newWidth,newHeight) {
this.originalWidth = originalWidth;
this.originalHeight = originalHeight;
this.newWidth = newWidth;
this.newHeight = newHeight;
}
AdaptiveLayoutManager.prototype.updateWindowWidth = function(width) {
this.newWidth = width;
}
AdaptiveLayoutManager.prototype.updateWindowHeight = function(height) {
this.newHeight = height;
}
AdaptiveLayoutManager.prototype.width = function(width) {
var factor = width / this.originalWidth;
var adaptiveWidth = factor * this.newWidth;
return adaptiveWidth;
}
AdaptiveLayoutManager.prototype.height = function(height) {
var factor = height / this.originalHeight;
var adaptiveHeight = factor * this.newHeight;
return adaptiveHeight;
}
AdaptiveLayoutManager.prototype.average = function(avg) {
var adaptiveAvg = ( this.height(avg) + this.width(avg)) /2
return adaptiveAvg;
}