fix a bug where in orientation=both icon lists with less than one screen full of icons, clicking below the icons would not cause a deselect
This commit is contained in:
parent
74873e3bfb
commit
2043dc7a12
1 changed files with 48 additions and 29 deletions
|
@ -425,28 +425,45 @@ Ox.List = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function emptyFirstPage() {
|
function emptyFirstPage() {
|
||||||
self.$pages[0] && self.$pages[0].find('.OxEmpty').remove();
|
if (self.$pages[0]) {
|
||||||
|
if (self.options.type == 'text') {
|
||||||
|
self.$pages[0].find('.OxEmpty').remove();
|
||||||
|
} else if (self.options.orientation == 'both') {
|
||||||
|
that.$content.css({height: getListSize() + 'px'});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function fillFirstPage() {
|
function fillFirstPage() {
|
||||||
if (self.$pages[0]) {
|
if (self.$pages[0]) {
|
||||||
var height = getHeight(),
|
if (self.options.type == 'text') {
|
||||||
lastItemHeight = height % self.options.itemHeight || self.options.itemHeight,
|
var height = getHeight(),
|
||||||
visibleItems = Math.ceil(height / self.options.itemHeight);
|
lastItemHeight = height % self.options.itemHeight || self.options.itemHeight,
|
||||||
if (self.listLength < visibleItems) {
|
visibleItems = Math.ceil(height / self.options.itemHeight);
|
||||||
Ox.range(self.listLength, visibleItems).forEach(function(v) {
|
if (self.listLength < visibleItems) {
|
||||||
var $item = Ox.ListItem({
|
Ox.range(self.listLength, visibleItems).forEach(function(v) {
|
||||||
construct: self.options.construct,
|
var $item = Ox.ListItem({
|
||||||
});
|
construct: self.options.construct,
|
||||||
$item.addClass('OxEmpty').removeClass('OxTarget');
|
});
|
||||||
if (v == visibleItems - 1) {
|
$item.addClass('OxEmpty').removeClass('OxTarget');
|
||||||
$item.$element.css({
|
if (v == visibleItems - 1) {
|
||||||
height: lastItemHeight + 'px',
|
$item.$element.css({
|
||||||
overflowY: 'hidden'
|
height: lastItemHeight + 'px',
|
||||||
});
|
overflowY: 'hidden'
|
||||||
}
|
});
|
||||||
$item.appendTo(self.$pages[0]);
|
}
|
||||||
});
|
$item.appendTo(self.$pages[0]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (self.options.orientation == 'both') {
|
||||||
|
var height = getHeight(),
|
||||||
|
listSize = getListSize();
|
||||||
|
if (listSize < height) {
|
||||||
|
that.$element.css({overflowY: 'hidden'});
|
||||||
|
that.$content.css({height: height + 'px'});
|
||||||
|
} else {
|
||||||
|
that.$element.css({overflowY: 'auto'});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -503,9 +520,9 @@ Ox.List = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getListSize() {
|
function getListSize() {
|
||||||
return Math.ceil(self.listLength * (self.options[
|
return Math.ceil(self.listLength / self.rowLength) * (self.options[
|
||||||
self.options.orientation == 'horizontal' ? 'itemWidth' : 'itemHeight'
|
self.options.orientation == 'horizontal' ? 'itemWidth' : 'itemHeight'
|
||||||
] + self.itemMargin) / self.rowLength);
|
] + self.itemMargin);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNext() {
|
function getNext() {
|
||||||
|
@ -623,9 +640,9 @@ Ox.List = function(options, self) {
|
||||||
function getPrevious() {
|
function getPrevious() {
|
||||||
var pos = -1;
|
var pos = -1;
|
||||||
if (self.selected.length) {
|
if (self.selected.length) {
|
||||||
pos = (self.options.orientation == 'both' ?
|
pos = (self.options.orientation == 'both'
|
||||||
self.selected[self.selected.length - 1] :
|
? self.selected[self.selected.length - 1]
|
||||||
Ox.min(self.selected)) - 1;
|
: Ox.min(self.selected)) - 1;
|
||||||
}
|
}
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
@ -635,9 +652,9 @@ Ox.List = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRowLength() {
|
function getRowLength() {
|
||||||
return self.options.orientation == 'both' ?
|
return self.options.orientation == 'both'
|
||||||
Math.floor((getWidth() - self.listMargin) /
|
? Math.floor((getWidth() - self.listMargin) /
|
||||||
(self.options.itemWidth + self.itemMargin)) : 1;
|
(self.options.itemWidth + self.itemMargin)) : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getScrollPosition() {
|
function getScrollPosition() {
|
||||||
|
@ -703,7 +720,7 @@ Ox.List = function(options, self) {
|
||||||
range = [offset, offset + getPageLength(page)];
|
range = [offset, offset + getPageLength(page)];
|
||||||
if (Ox.isUndefined(self.$pages[page])) { // fixme: unload will have made this undefined already
|
if (Ox.isUndefined(self.$pages[page])) { // fixme: unload will have made this undefined already
|
||||||
self.$pages[page] = constructEmptyPage(page);
|
self.$pages[page] = constructEmptyPage(page);
|
||||||
self.options.type == 'text' && page == 0 && fillFirstPage();
|
page == 0 && fillFirstPage();
|
||||||
self.$pages[page].appendTo(that.$content);
|
self.$pages[page].appendTo(that.$content);
|
||||||
self.requests.push(self.options.items({
|
self.requests.push(self.options.items({
|
||||||
keys: keys,
|
keys: keys,
|
||||||
|
@ -725,7 +742,7 @@ Ox.List = function(options, self) {
|
||||||
isSelected(pos) && self.$items[pos].addClass('OxSelected');
|
isSelected(pos) && self.$items[pos].addClass('OxSelected');
|
||||||
self.$items[pos].appendTo(self.$pages[page]);
|
self.$items[pos].appendTo(self.$pages[page]);
|
||||||
});
|
});
|
||||||
self.options.type == 'text' && page == 0 && fillFirstPage();
|
page == 0 && fillFirstPage();
|
||||||
// fixme: why does emptyPage sometimes have no methods?
|
// fixme: why does emptyPage sometimes have no methods?
|
||||||
//Ox.print('emptyPage', $emptyPage)
|
//Ox.print('emptyPage', $emptyPage)
|
||||||
$emptyPage.removeElement && $emptyPage.removeElement();
|
$emptyPage.removeElement && $emptyPage.removeElement();
|
||||||
|
@ -1558,6 +1575,8 @@ Ox.List = function(options, self) {
|
||||||
});
|
});
|
||||||
scrollTo(scroll);
|
scrollTo(scroll);
|
||||||
}
|
}
|
||||||
|
emptyFirstPage();
|
||||||
|
fillFirstPage();
|
||||||
} else if (self.options.type == 'text') {
|
} else if (self.options.type == 'text') {
|
||||||
emptyFirstPage();
|
emptyFirstPage();
|
||||||
fillFirstPage();
|
fillFirstPage();
|
||||||
|
|
Loading…
Reference in a new issue