Skip to content

Commit

Permalink
Merge pull request #152 from alvarotrigo/dev
Browse files Browse the repository at this point in the history
Merging dev branch 0.1.16
  • Loading branch information
alvarotrigo authored Aug 18, 2019
2 parents 0d9315a + 8f9d13d commit 89c507a
Show file tree
Hide file tree
Showing 9 changed files with 1,145 additions and 889 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<p align="center">Official React wrapper for the <a target="_blank" href="https://github.com/alvarotrigo/fullPage.js/">fullpage.js library</a></p>

<p align="center">
<img src="https://img.shields.io/badge/react--fullpage-v0.1.15-brightgreen.svg" alt="react-fullpage version" />
<img src="https://img.shields.io/badge/react--fullpage-v0.1.16-brightgreen.svg" alt="react-fullpage version" />
</p>

- [Demo online](https://alvarotrigo.com/react-fullpage/) | [CodeSandbox](https://codesandbox.io/s/m34yq5q0qx)
Expand Down
21 changes: 13 additions & 8 deletions components/ReactFullpage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import {
let Fullpage;

const isFunc = val => typeof val === 'function';
const isEqualArray = (firstArr, secondArr) => {
if (firstArr.length !== secondArr.length) return false;

return firstArr.find(el => !secondArr.includes(el)) == null;
};
const fullpageCallbacks = [
'afterLoad',
'afterRender',
Expand Down Expand Up @@ -65,18 +70,14 @@ class ReactFullpage extends React.Component {
}
}

componentDidUpdate(prevProps, prevState) {
componentDidUpdate(prevProps) {
this.log('React Lifecycle: componentDidUpdate()');
const newSectionCount = this.getSectionCount();
const newSlideCount = this.getSlideCount();
const { sectionCount, slideCount } = this.state;

//comparing sectionColors array option
var areSameSectionColors = true;
this.props.sectionsColor.forEach(function(item, index) {
areSameSectionColors =
item === prevProps.sectionsColor[index] && areSameSectionColors;
});
// comparing sectionColors array option
const areSameSectionColors = isEqualArray(prevProps.sectionsColor, this.props.sectionsColor);

// NOTE: if fullpage props have changed we need to rebuild
if (!areSameSectionColors) {
Expand Down Expand Up @@ -124,7 +125,7 @@ class ReactFullpage extends React.Component {

init(opts) {
this.log('Reinitializing fullpage with options', opts);
new Fullpage(ID_SELECTOR, opts) // eslint-disable-line
new Fullpage(ID_SELECTOR, opts); // eslint-disable-line
this.fullpageApi = window.fullpage_api;
this.fpUtils = window.fp_utils;
this.fpEasings = window.fp_easings;
Expand Down Expand Up @@ -243,4 +244,8 @@ class ReactFullpage extends React.Component {
}
}

ReactFullpage.defaultProps = {
sectionsColor: []
}

export default ReactFullpage;
Loading

0 comments on commit 89c507a

Please sign in to comment.