simplify size calculation when using fixed ratio
This commit is contained in:
parent
cd298c2486
commit
27fc41526f
1 changed files with 4 additions and 8 deletions
|
@ -111,19 +111,15 @@ pandora.ui.list = function(view) { // fixme: remove view argument
|
||||||
} else if (view == 'calendars') {
|
} else if (view == 'calendars') {
|
||||||
that = Ox.Element().css({margin: '16px'}).html(view + ' results view still missing.');
|
that = Ox.Element().css({margin: '16px'}).html(view + ' results view still missing.');
|
||||||
} else if (view == 'clip') {
|
} else if (view == 'clip') {
|
||||||
|
var fixedRatio = 16/9;
|
||||||
that = Ox.IconList({
|
that = Ox.IconList({
|
||||||
fixedRatio: 4/3,
|
fixedRatio: fixedRatio,
|
||||||
item: function(data, sort, size) {
|
item: function(data, sort, size) {
|
||||||
size = size || 128;
|
size = size || 128;
|
||||||
var ratio = data.aspectRatio,
|
var ratio = data.aspectRatio,
|
||||||
width = ratio > 1 ? size : Math.round(size * ratio),
|
width = ratio > fixedRatio ? size : Math.round(size * ratio / fixedRatio),
|
||||||
height = ratio > 1 ? Math.round(size / ratio) : size,
|
height = Math.round(width / ratio),
|
||||||
url = '/' + data.item + '/' + height + 'p' + data['in'] + '.jpg';
|
url = '/' + data.item + '/' + height + 'p' + data['in'] + '.jpg';
|
||||||
// fixme: ugly
|
|
||||||
if (height > 96) {
|
|
||||||
width = Math.round(width * 96 / height);
|
|
||||||
height = 96;
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
height: height,
|
height: height,
|
||||||
id: data['id'],
|
id: data['id'],
|
||||||
|
|
Loading…
Reference in a new issue