react-responsive-carousel
Advanced tools
Comparing version 3.1.10 to 3.1.11
# React Responsive Carousel | ||
## 3.1.10 - Tue Apr 25 2017 | ||
* Merge pull request #110 from leandrowd/issue-109 | ||
> #109: Move create-react-class to dependencies instead of devDependencies | ||
## 3.1.9 - Mon Apr 24 2017 | ||
@@ -123,11 +128,5 @@ * Merge pull request #108 from leandrowd/issue-98 | ||
* Adding example with videos | ||
* Merge pull request #56 from tenshiemi/use-babelify-for-es6 | ||
> Replacing the deprecated package reactify with babelify | ||
* Replacing the deprecated package reactify with babelify | ||
## 3.0.16 - Sat Sep 10 2016 | ||
* Merge pull request #54 from leandrowd/storybook | ||
> Storybook and many adjusts resulting from tests inside it. | ||
* Updating editor config properties and reformatting files | ||
@@ -134,0 +133,0 @@ |
@@ -22,2 +22,3 @@ 'use strict'; | ||
propTypes: { | ||
className: PropTypes.string, | ||
children: PropTypes.node, | ||
@@ -67,3 +68,2 @@ showArrows: PropTypes.bool, | ||
return { | ||
// index of the image to be shown. | ||
initialized: false, | ||
@@ -112,2 +112,6 @@ selectedItem: this.props.selectedItem, | ||
this.setState({ | ||
initialized: true | ||
}); | ||
var initialImage = this.getInitialImage(); | ||
@@ -120,6 +124,2 @@ if (initialImage) { | ||
} | ||
this.setState({ | ||
initialized: true | ||
}); | ||
}, | ||
@@ -391,3 +391,3 @@ destroyCarousel: function destroyCarousel() { | ||
renderThumbs: function renderThumbs() { | ||
if (!this.props.showThumbs) { | ||
if (!this.props.showThumbs || this.props.children.length === 0) { | ||
return null; | ||
@@ -433,3 +433,3 @@ } | ||
render: function render() { | ||
if (!this.props.children) { | ||
if (!this.props.children || this.props.children.length === 0) { | ||
return null; | ||
@@ -440,6 +440,2 @@ } | ||
if (itemsLength === 0) { | ||
return null; | ||
} | ||
var isHorizontal = this.props.axis === 'horizontal'; | ||
@@ -446,0 +442,0 @@ |
@@ -32,2 +32,3 @@ 'use strict'; | ||
return { | ||
initialized: false, | ||
selectedItem: this.props.selectedItem, | ||
@@ -38,2 +39,9 @@ hasMount: false, | ||
}, | ||
componentDidMount: function componentDidMount(nextProps) { | ||
if (!this.props.children) { | ||
return; | ||
} | ||
this.setupThumbs(); | ||
}, | ||
componentWillReceiveProps: function componentWillReceiveProps(props, state) { | ||
@@ -47,12 +55,24 @@ if (props.selectedItem !== this.state.selectedItem) { | ||
}, | ||
componentDidMount: function componentDidMount(nextProps) { | ||
componentDidUpdate: function componentDidUpdate(prevProps) { | ||
if (!prevProps.children && this.props.children && !this.state.initialized) { | ||
this.setupThumbs(); | ||
} | ||
}, | ||
componentWillUnmount: function componentWillUnmount() { | ||
this.destroyThumbs(); | ||
}, | ||
setupThumbs: function setupThumbs() { | ||
// as the widths are calculated, we need to resize | ||
// the carousel when the window is resized | ||
window.addEventListener("resize", this.updateStatics); | ||
window.addEventListener("resize", this.updateSizes); | ||
// issue #2 - image loading smaller | ||
window.addEventListener("DOMContentLoaded", this.updateStatics); | ||
window.addEventListener("DOMContentLoaded", this.updateSizes); | ||
this.setState({ | ||
initialized: true | ||
}); | ||
var defaultImg = this.getDefaultImage(); | ||
if (defaultImg) { | ||
defaultImg.addEventListener('load', this.onFirstImageLoad); | ||
defaultImg.addEventListener('load', this.setMountState); | ||
} | ||
@@ -62,15 +82,19 @@ | ||
// the container size to adjust the responsive behaviour | ||
this.updateStatics(); | ||
this.updateSizes(); | ||
}, | ||
componentWillUnmount: function componentWillUnmount() { | ||
destroyThumbs: function destroyThumbs() { | ||
// removing listeners | ||
window.removeEventListener("resize", this.updateStatics); | ||
window.removeEventListener("DOMContentLoaded", this.updateStatics); | ||
window.removeEventListener("resize", this.updateSizes); | ||
window.removeEventListener("DOMContentLoaded", this.updateSizes); | ||
var defaultImg = this.getDefaultImage(); | ||
if (defaultImg) { | ||
defaultImg.removeEventListener('load', this.onFirstImageLoad); | ||
defaultImg.removeEventListener('load', this.setMountState); | ||
} | ||
}, | ||
updateStatics: function updateStatics() { | ||
updateSizes: function updateSizes() { | ||
if (!this.state.initialized) { | ||
return; | ||
} | ||
var total = this.props.children.length; | ||
@@ -93,5 +117,5 @@ this.wrapperSize = this.itemsWrapper.clientWidth; | ||
}, | ||
onFirstImageLoad: function onFirstImageLoad() { | ||
setMountState: function setMountState() { | ||
this.setState({ hasMount: true }); | ||
this.updateStatics(); | ||
this.updateSizes(); | ||
}, | ||
@@ -98,0 +122,0 @@ handleClickItem: function handleClickItem(index, item) { |
{ | ||
"name": "react-responsive-carousel", | ||
"version": "3.1.10", | ||
"version": "3.1.11", | ||
"description": "React Responsive Carousel", | ||
@@ -29,2 +29,3 @@ "author": { | ||
"test": "jest", | ||
"prepare-snapshot": "jest --updateSnapshot", | ||
"prebuild": "npm test", | ||
@@ -89,3 +90,4 @@ "build": "babel ./src -d lib --ignore '__tests__' && gulp styles:package copy:package", | ||
"node_modules" | ||
] | ||
], | ||
"rootDir": "src" | ||
}, | ||
@@ -92,0 +94,0 @@ "dependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1183514
1574