Skip to content

Commit

Permalink
IE 11 support (Array.from replace to its analogs)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaeverywhere committed Sep 13, 2017
1 parent 1763ff8 commit 3a61c2b
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.js

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions docs/jsx/utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,21 @@ export function getRandomText (length = undefined) {
}

export function generateArticles () {
return Array.from({ length: 7 + Math.floor(Math.random() * 5) },
() => ({

let arr = new Array(7 + Math.floor(Math.random() * 5));

for (let i = 0; i < arr.length; ++i) {
arr[i] = {
id: ++globalID,
title: getRandomText(1).slice(0, 50),
text: `${ getRandomText() }.`,
cover: `https://source.unsplash.com/random/1600x900.${ Math.random().toString().slice(2) }`,
cardWidth: Math.random() > 0.8 ? 2 : 1
})
);
};
}

return arr;

}

export function getRandomCard (id) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-xmasonry",
"version": "2.5.1",
"version": "2.5.2",
"description": "Simple & featured native masonry layout implementation for React JS",
"main": "dist/index.js",
"module": "src/index.jsx",
Expand Down
2 changes: 1 addition & 1 deletion src/components/XBlock.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class XBlock extends React.Component {
this.placed = true;
const parent = this.props.parent;
requestAnimationFrame(() => { if (!this.divElement) return;
let images = Array.from(this.divElement.querySelectorAll(`img`)),
let images = Array.prototype.slice.call(this.divElement.querySelectorAll(`img`)),
handleImages = images.length > 0 && parent.props.updateOnImagesLoad;
if (handleImages) images.forEach(
(img) => !img.complete && img.addEventListener(`load`, parent.update)
Expand Down
5 changes: 4 additions & 1 deletion src/components/XMasonry.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,10 @@ export default class XMasonry extends React.Component {
recalculatePositions (newBlocks = null, deletedBlocks = null) {

let blocks,
heights = Array.from({ length: this.columns }, () => 0);
heights = [];

for (let c = 0; c < this.columns; ++c)
heights.push(0);

for (const key in this.blocks) {
if (this.blocks.hasOwnProperty(key) && typeof this.blocks[key] === "undefined") {
Expand Down

0 comments on commit 3a61c2b

Please sign in to comment.