Skip to content

Changed floor to ceil in _getGridHeight because floor is a bug #14

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
28 changes: 14 additions & 14 deletions dist/grid.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

Object.defineProperty(exports, "__esModule", {
value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _react = require('react');

var _react2 = _interopRequireDefault(_react);
Expand All @@ -24,7 +24,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var InfiniteGrid = (function (_React$Component) {
var InfiniteGrid = function (_React$Component) {
_inherits(InfiniteGrid, _React$Component);

_createClass(InfiniteGrid, [{
Expand Down Expand Up @@ -63,15 +63,15 @@ var InfiniteGrid = (function (_React$Component) {
function InfiniteGrid(props) {
_classCallCheck(this, InfiniteGrid);

var _this2 = _possibleConstructorReturn(this, Object.getPrototypeOf(InfiniteGrid).call(this, props));
var _this = _possibleConstructorReturn(this, (InfiniteGrid.__proto__ || Object.getPrototypeOf(InfiniteGrid)).call(this, props));

_this2.state = _this2.initialState();
_this.state = _this.initialState();
// bind the functions
_this2._scrollListener = _this2._scrollListener.bind(_this2);
_this2._updateItemDimensions = _this2._updateItemDimensions.bind(_this2);
_this2._resizeListener = _this2._resizeListener.bind(_this2);
_this2._visibleIndexes = _this2._visibleIndexes.bind(_this2);
return _this2;
_this._scrollListener = _this._scrollListener.bind(_this);
_this._updateItemDimensions = _this._updateItemDimensions.bind(_this);
_this._resizeListener = _this._resizeListener.bind(_this);
_this._visibleIndexes = _this._visibleIndexes.bind(_this);
return _this;
}

// METHODS
Expand Down Expand Up @@ -105,7 +105,7 @@ var InfiniteGrid = (function (_React$Component) {
}, {
key: '_getGridHeight',
value: function _getGridHeight() {
return Math.floor(this.props.entries.length / this.state.itemDimensions.itemsPerRow) * this.state.itemDimensions.height;
return this.props.entries.length < this.state.itemDimensions.itemsPerRow ? this.state.itemDimensions.height : Math.ceil(this.props.entries.length / this.state.itemDimensions.itemsPerRow) * this.state.itemDimensions.height;
}
}, {
key: '_getWrapperRect',
Expand Down Expand Up @@ -243,11 +243,11 @@ var InfiniteGrid = (function (_React$Component) {
}, {
key: '_scrollListener',
value: function _scrollListener(event) {
var _this = this;
var _this2 = this;

clearTimeout(this.scrollOffset);
this.scrollOffset = setTimeout(function () {
_this._visibleIndexes();
_this2._visibleIndexes();
}, 10);
}
}, {
Expand Down Expand Up @@ -301,7 +301,7 @@ var InfiniteGrid = (function (_React$Component) {
}]);

return InfiniteGrid;
})(_react2.default.Component);
}(_react2.default.Component);

exports.default = InfiniteGrid;
;
Expand Down
10 changes: 5 additions & 5 deletions dist/item.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

Object.defineProperty(exports, "__esModule", {
value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _react = require('react');

var _react2 = _interopRequireDefault(_react);
Expand All @@ -20,13 +20,13 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var Item = (function (_React$Component) {
var Item = function (_React$Component) {
_inherits(Item, _React$Component);

function Item(props) {
_classCallCheck(this, Item);

return _possibleConstructorReturn(this, Object.getPrototypeOf(Item).call(this, props));
return _possibleConstructorReturn(this, (Item.__proto__ || Object.getPrototypeOf(Item)).call(this, props));
}

_createClass(Item, [{
Expand Down Expand Up @@ -85,6 +85,6 @@ var Item = (function (_React$Component) {
}]);

return Item;
})(_react2.default.Component);
}(_react2.default.Component);

exports.default = Item;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"license": "MIT",
"dependencies": {
"lodash": "^3.10.1",
"react": "^0.14.2",
"react-dom": "^0.14.2"
"react": "^15.3.0",
"react-dom": "^15.3.0"
},
"devDependencies": {
"babel": "^6.1.18",
Expand Down
2 changes: 1 addition & 1 deletion src/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class InfiniteGrid extends React.Component {
_getGridHeight() {
return (this.props.entries.length < this.state.itemDimensions.itemsPerRow) ?
this.state.itemDimensions.height :
Math.floor(this.props.entries.length / this.state.itemDimensions.itemsPerRow) * this.state.itemDimensions.height;
Math.ceil(this.props.entries.length / this.state.itemDimensions.itemsPerRow) * this.state.itemDimensions.height;
}

_getWrapperRect() {
Expand Down