Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable grid layout when only one column is present. #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 33 additions & 25 deletions angulargrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,41 +478,49 @@
//set new positions
for (i = 0, ln = listElms.length; i < ln; i++) {
item = single(listElms[i]);
var height = listElmHeights[i],
top = Math.min.apply(Math, lastRowBottom),
col = lastRowBottom.indexOf(top);

//update lastRowBottom value
lastRowBottom[col] = top + height + options.gutterSize;

//set top and left of list items
var posX = col * (colWidth + options.gutterSize);

var cssObj = {
position: 'absolute',
top: top + 'px'
left: null,
position: null,
right: null,
top: null,
width: null,
};
if (cols > 1) {
var height = listElmHeights[i],
top = Math.min.apply(Math, lastRowBottom),
col = lastRowBottom.indexOf(top);

if (options.direction == 'rtol') {
cssObj.right = posX + 'px';
} else {
cssObj.left = posX + 'px';
}
//update lastRowBottom value
lastRowBottom[col] = top + height + options.gutterSize;

cssObj.width = colWidth + 'px';
//set top and left of list items
var posX = col * (colWidth + options.gutterSize);

//add position info of each grids
listElmPosInfo.push({
top: top,
bottom: top + height
});
cssObj.position = 'absolute';
cssObj.top = top + 'px';

if (options.direction == 'rtol') {
cssObj.right = posX + 'px';
} else {
cssObj.left = posX + 'px';
}

cssObj.width = colWidth + 'px';

//add position info of each grids
listElmPosInfo.push({
top: top,
bottom: top + height
});
}
item.css(cssObj).addClass('angular-grid-item');
}

//set the height of container
var contHeight = Math.max.apply(Math, lastRowBottom);
element.css('height', contHeight + 'px');
var contHeight = Math.max.apply(Math, lastRowBottom),
setHeight = cols > 1 ? contHeight + 'px' : null;

element.css('height', setHeight);

clones.remove();

Expand Down