|
2 | 2 | import { computeCellMetadataAndUpdateScrollOffsetHelper, createCallbackMemoizer, getOverscanIndices, getUpdatedOffsetForIndex, getVisibleCellIndices, initCellMetadata, updateScrollIndexHelper } from '../utils'; |
3 | 3 | import cn from 'classnames'; |
4 | 4 | import raf from 'raf'; |
| 5 | +import getScrollbarSize from 'dom-helpers/util/scrollbarSize'; |
5 | 6 | import React, { Component, PropTypes } from 'react'; |
6 | 7 | import shouldPureComponentUpdate from 'react-pure-render/function'; |
7 | 8 |
|
@@ -127,6 +128,8 @@ var Grid = function (_Component) { |
127 | 128 | var scrollToRow = _props.scrollToRow; |
128 | 129 |
|
129 | 130 |
|
| 131 | + this._scrollbarSize = getScrollbarSize(); |
| 132 | + |
130 | 133 | if (scrollLeft >= 0 || scrollTop >= 0) { |
131 | 134 | this.setScrollPosition({ scrollLeft: scrollLeft, scrollTop: scrollTop }); |
132 | 135 | } |
@@ -347,6 +350,13 @@ var Grid = function (_Component) { |
347 | 350 | var columnDatum = this._columnMetadata[columnIndex]; |
348 | 351 | var renderedCell = renderCell({ columnIndex: columnIndex, rowIndex: rowIndex }); |
349 | 352 | var key = rowIndex + '-' + columnIndex; |
| 353 | + |
| 354 | + // any other falsey value will be rendered |
| 355 | + // as a text node by React |
| 356 | + if (renderedCell == null || renderedCell === false) { |
| 357 | + continue; |
| 358 | + } |
| 359 | + |
350 | 360 | var child = React.createElement( |
351 | 361 | 'div', |
352 | 362 | { |
@@ -691,10 +701,11 @@ var Grid = function (_Component) { |
691 | 701 | var height = _props6.height; |
692 | 702 | var width = _props6.width; |
693 | 703 |
|
| 704 | + var scrollbarSize = this._scrollbarSize; |
694 | 705 | var totalRowsHeight = this._getTotalRowsHeight(); |
695 | 706 | var totalColumnsWidth = this._getTotalColumnsWidth(); |
696 | | - var scrollLeft = Math.min(totalColumnsWidth - width, event.target.scrollLeft); |
697 | | - var scrollTop = Math.min(totalRowsHeight - height, event.target.scrollTop); |
| 707 | + var scrollLeft = Math.min(totalColumnsWidth - width + scrollbarSize, event.target.scrollLeft); |
| 708 | + var scrollTop = Math.min(totalRowsHeight - height + scrollbarSize, event.target.scrollTop); |
698 | 709 |
|
699 | 710 | // Certain devices (like Apple touchpad) rapid-fire duplicate events. |
700 | 711 | // Don't force a re-render if this is the case. |
|
0 commit comments