Skip to content

Commit

Permalink
Fixed background selector issue on mobile search (#1879)
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap authored May 24, 2017
1 parent 2fad4d5 commit e905160
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
6 changes: 0 additions & 6 deletions web/client/components/background/BackgroundSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ const BackgroundSelector = React.createClass({
this.props.onLayerChange('tempLayer', {});
this.props.onStartChange(0);
},
componentWillUpdate(nextProps) {
if (this.props.size.width !== nextProps.size.width
|| this.props.size.height !== nextProps.size.height) {
this.props.onStartChange(0);
}
},
getThumb(layer) {
return this.props.thumbs[layer.source] && this.props.thumbs[layer.source][layer.name] || layer.thumbURL || this.props.thumbs.unknown;
},
Expand Down
4 changes: 2 additions & 2 deletions web/client/components/background/PreviewList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ const PreviewList = React.createClass({
},
render() {
let iconButtons = [].concat(this.props.icons);
iconButtons = iconButtons.slice(this.props.start, this.props.start + this.props.length);
iconButtons = this.props.pagination ? iconButtons.slice(this.props.start, this.props.start + this.props.length) : iconButtons;
if (this.props.pagination) {
if (this.props.start !== 0) {
iconButtons.unshift(<PaginationButton key="pagination_0" vertical={this.props.vertical} side={this.props.vertical ? this.props.width : this.props.height} direction={false} onClick={ () => { this.props.onStartChange(this.props.start - 1); }} />);
}
if (this.props.start + this.props.length !== this.props.icons.length) {
if (this.props.start + this.props.length < this.props.icons.length) {
iconButtons.push(<PaginationButton key="pagination_1" vertical={this.props.vertical} side={this.props.vertical ? this.props.width : this.props.height} direction={true} onClick={ () => { this.props.onStartChange(this.props.start + 1); } } />);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ describe("test the BackgroundSelector", () => {
const node = ReactDOM.findDOMNode(backgroundSelector);
expect(node).toExist();

backgroundSelector.componentWillUpdate({size: {width: 1000, height: 400}, drawerEnabled: false});
backgroundSelector.componentWillUpdate({size: {width: 900, height: 500}, drawerEnabled: false});
backgroundSelector.componentWillUpdate({size: {width: 1000, height: 500}, drawerEnabled: true});
backgroundSelector.componentWillUpdate({size: {width: 1000, height: 500}, drawerEnabled: false});

const icons = backgroundSelector.getIcons(5, 5, 5, false);
expect(icons.length).toBeGreaterThan(0);

Expand Down

0 comments on commit e905160

Please sign in to comment.