diff --git a/app/actuators/ResultCard.js b/app/actuators/ResultCard.js index de137e51ac..92991edce9 100644 --- a/app/actuators/ResultCard.js +++ b/app/actuators/ResultCard.js @@ -565,19 +565,15 @@ export default class ResultCard extends Component { function setScroll(node) { if (node) { node.addEventListener("scroll", () => { - if (this.state.requestOnScroll && $(node).scrollTop() + $(node).innerHeight() >= node.scrollHeight && this.state.resultStats.total > this.state.currentData.length && !this.state.queryStart) { + const scrollHeight = node.scrollHeight || node.scrollHeight === 0 ? node.scrollHeight : $(node).height(); + if (this.state.requestOnScroll && $(node).scrollTop() + $(node).innerHeight() >= scrollHeight && this.state.resultStats.total > this.state.currentData.length && !this.state.queryStart) { this.nextPage(); } }); } } - - if (this.props.scrollOnWindow) { - $(window).on("scroll", () => { - if (this.state.requestOnScroll && $(window).scrollTop() + $(window).innerHeight() >= $(window).height() && this.state.resultStats.total > this.state.currentData.length && !this.state.queryStart) { - this.nextPage(); - } - }); + if (this.props.scrollOnTarget) { + setScroll.call(this, this.props.scrollOnTarget); } else { setScroll.call(this, this.listParentElement); setScroll.call(this, this.listChildElement); @@ -668,7 +664,10 @@ export default class ResultCard extends Component { ResultCard.propTypes = { componentId: React.PropTypes.string, appbaseField: React.PropTypes.string, - title: React.PropTypes.string, + title: React.PropTypes.oneOfType([ + React.PropTypes.string, + React.PropTypes.element + ]), sortBy: React.PropTypes.oneOf(["asc", "desc", "default"]), sortOptions: React.PropTypes.arrayOf( React.PropTypes.shape({ @@ -699,7 +698,7 @@ ResultCard.propTypes = { React.PropTypes.element ]), react: React.PropTypes.object, - scrollOnWindow: React.PropTypes.bool + scrollOnTarget: React.PropTypes.object }; ResultCard.defaultProps = { @@ -736,5 +735,5 @@ ResultCard.types = { showResultStats: TYPES.BOOLEAN, onResultStats: TYPES.FUNCTION, placeholder: TYPES.STRING, - scrollOnWindow: TYPES.BOOLEAN + scrollOnTarget: TYPES.OBJECT }; diff --git a/app/actuators/ResultList.js b/app/actuators/ResultList.js index 09b831ca5c..8f1721002c 100644 --- a/app/actuators/ResultList.js +++ b/app/actuators/ResultList.js @@ -568,19 +568,15 @@ export default class ResultList extends Component { function setScroll(node) { if (node) { node.addEventListener("scroll", () => { - if (this.state.requestOnScroll && $(node).scrollTop() + $(node).innerHeight() >= node.scrollHeight && this.state.resultStats.total > this.state.currentData.length && !this.state.queryStart) { + const scrollHeight = node.scrollHeight || node.scrollHeight === 0 ? node.scrollHeight : $(node).height(); + if (this.state.requestOnScroll && $(node).scrollTop() + $(node).innerHeight() >= scrollHeight && this.state.resultStats.total > this.state.currentData.length && !this.state.queryStart) { this.nextPage(); } }); } } - - if (this.props.scrollOnWindow) { - $(window).on("scroll", () => { - if (this.state.requestOnScroll && $(window).scrollTop() + $(window).innerHeight() >= $(window).height() && this.state.resultStats.total > this.state.currentData.length && !this.state.queryStart) { - this.nextPage(); - } - }); + if (this.props.scrollOnTarget) { + setScroll.call(this, this.props.scrollOnTarget); } else { setScroll.call(this, this.listParentElement); setScroll.call(this, this.listChildElement); @@ -671,7 +667,10 @@ export default class ResultList extends Component { ResultList.propTypes = { componentId: React.PropTypes.string, appbaseField: React.PropTypes.string, - title: React.PropTypes.string, + title: React.PropTypes.oneOfType([ + React.PropTypes.string, + React.PropTypes.element + ]), sortBy: React.PropTypes.oneOf(["asc", "desc", "default"]), sortOptions: React.PropTypes.arrayOf( React.PropTypes.shape({ @@ -702,7 +701,7 @@ ResultList.propTypes = { React.PropTypes.element ]), react: React.PropTypes.object, - scrollOnWindow: React.PropTypes.bool + scrollOnTarget: React.PropTypes.object }; ResultList.defaultProps = { @@ -739,5 +738,5 @@ ResultList.types = { showResultStats: TYPES.BOOLEAN, onResultStats: TYPES.FUNCTION, placeholder: TYPES.STRING, - scrollOnWindow: TYPES.BOOLEAN + scrollOnTarget: TYPES.OBJECT }; diff --git a/app/actuators/ViewSwitcher.js b/app/actuators/ViewSwitcher.js index e4f0906bb4..639f063e11 100644 --- a/app/actuators/ViewSwitcher.js +++ b/app/actuators/ViewSwitcher.js @@ -49,7 +49,7 @@ export default class ViewSwitcher extends Component { render() { return ( -
+
{this.renderItems()}
@@ -57,3 +57,11 @@ export default class ViewSwitcher extends Component { ); } } + +ViewSwitcher.propTypes = { + componentStyle: React.PropTypes.object +}; + +ViewSwitcher.defaultProps = { + componentStyle: {} +}; \ No newline at end of file diff --git a/app/sensors/CategorySearch.js b/app/sensors/CategorySearch.js index e281020519..e4d63cdd22 100644 --- a/app/sensors/CategorySearch.js +++ b/app/sensors/CategorySearch.js @@ -325,7 +325,7 @@ export default class CategorySearch extends Component { }); return ( -
+
{title}