Skip to content

Commit

Permalink
ColumnSet: fix clicking in scrollbar "gap" in IE and fix bodyNode adj…
Browse files Browse the repository at this point in the history
…ustment
  • Loading branch information
Kenneth G. Franqueiro committed Dec 21, 2012
1 parent 9785205 commit 88e565b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 13 deletions.
18 changes: 14 additions & 4 deletions ColumnSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ function(kernel, declare, Deferred, listen, aspect, query, has, put, hasClass, G
scrollers = grid._columnSetScrollers,
scrollerContents = grid._columnSetScrollerContents,
columnSets = grid.columnSets,
left = 0, scrollerWidth = 0,
left = 0,
scrollerWidth = 0,
numScrollers = 0, // tracks number of visible scrollers (sets w/ overflow)
i, l, columnSetElement, contentWidth;

for(i = 0, l = columnSets.length; i < l; i++){
// iterate through the columnSets
left += scrollerWidth;
Expand All @@ -34,9 +37,17 @@ function(kernel, declare, Deferred, listen, aspect, query, has, put, hasClass, G
contentWidth = columnSetElement.firstChild.offsetWidth;
scrollerContents[i].style.width = contentWidth + "px";
scrollers[i].style.width = scrollerWidth + "px";
scrollers[i].style.overflowX = contentWidth > scrollerWidth ? "scroll" : "auto"; // IE seems to need it be set explicitly
// IE seems to need scroll to be set explicitly
scrollers[i].style.overflowX = contentWidth > scrollerWidth ? "scroll" : "auto";
scrollers[i].style.left = left + "px";
}
// Keep track of how many scrollbars we're showing
if(contentWidth > scrollerWidth){ numScrollers++; }
}

// Align bottom of body node depending on whether there are scrollbars
grid.bodyNode.style.bottom = numScrollers ?
(has("dom-scrollbar-height") + (has("ie") ? 1 : 0) + "px") :
"0";
}
function adjustScrollLeft(grid, row){
var scrollLefts = grid._columnSetScrollLefts;
Expand Down Expand Up @@ -146,7 +157,6 @@ function(kernel, declare, Deferred, listen, aspect, query, has, put, hasClass, G
// summary:
// Setup the headers for the grid
this.inherited(arguments);
this.bodyNode.style.bottom = "17px";

var columnSets = this.columnSets,
domNode = this.domNode,
Expand Down
41 changes: 32 additions & 9 deletions List.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,32 @@ function(arrayUtil, kernel, declare, listen, has, miscUtil, TouchScroll, hasClas

var oddClass = "dgrid-row-odd",
evenClass = "dgrid-row-even",
scrollbarWidth;

scrollbarWidth, scrollbarHeight;
function byId(id){
return document.getElementById(id);
}


function getScrollbarSize(node, dimension){
// Used by has tests for scrollbar width/height
var body = document.body,
size;

put(body, node, ".dgrid-scrollbar-measure");
size = node["offset" + dimension] - node["client" + dimension];

put(node, "!dgrid-scrollbar-measure");
body.removeChild(node);

return size;
}
has.add("dom-scrollbar-width", function(global, doc, element){
return getScrollbarSize(element, "Width");
});
has.add("dom-scrollbar-height", function(global, doc, element){
return getScrollbarSize(element, "Height");
});

// var and function for autogenerating ID when one isn't provided
var autogen = 0;
function generateId(){
Expand Down Expand Up @@ -245,16 +265,19 @@ function(arrayUtil, kernel, declare, listen, has, miscUtil, TouchScroll, hasClas

if(!scrollbarWidth){
// Measure the browser's scrollbar width using a DIV we'll delete right away
var scrollDiv = put(document.body, "div.dgrid-scrollbar-measure");
scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
put(scrollDiv, "!");
scrollbarWidth = has("dom-scrollbar-width");
scrollbarHeight = has("dom-scrollbar-height");

// avoid crazy issues in IE7 only, with certain widgets inside
if(has("ie") === 7){ scrollbarWidth++; }
// Avoid issues with certain widgets inside in IE7, and
// ColumnSet scroll issues with all supported IE versions
if(has("ie")){
scrollbarWidth++;
scrollbarHeight++;
}

// add rules that can be used where scrollbar width/height is needed
miscUtil.addCssRule(".dgrid-scrollbar-width", "width: " + scrollbarWidth + "px");
miscUtil.addCssRule(".dgrid-scrollbar-height", "height: " + scrollbarWidth + "px");
miscUtil.addCssRule(".dgrid-scrollbar-height", "height: " + scrollbarHeight + "px");

if(scrollbarWidth != 17 && !quirks){
// for modern browsers, we can perform a one-time operation which adds
Expand Down

0 comments on commit 88e565b

Please sign in to comment.