Skip to content

Instantly share code, notes, and snippets.

@jeffvan576
Last active February 3, 2017 22:25
Show Gist options
  • Save jeffvan576/dd6ad36869fff28be9043d9e28307135 to your computer and use it in GitHub Desktop.
Save jeffvan576/dd6ad36869fff28be9043d9e28307135 to your computer and use it in GitHub Desktop.
// Import scrollbar size helper
import scrollbarSize from 'dom-helpers/util/scrollbarSize';
// Helper function
adjusted (width, height) {
const {
columnWidth,
columnCount,
rowHeight,
rowCount,
} = this.state;
const totalGridWidth = columnWidth * columnCount;
const totalGridHeight = rowHeight * rowCount;
const widthTest = totalGridWidth > width;
const heightTest = totalGridHeight > height && widthTest;
return {
width: widthTest ? width - scrollbarSize() : width,
height: heightTest ? height - scrollbarSize() : height,
};
}
// Grid / Autosizer implementation
<AutoSizer>
{({ width, height }) => {
const adjustedMeasurement = this.adjusted(width, height);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment