Skip to content

Commit

Permalink
Some example fixes (visgl#1878)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibgreen authored Jun 1, 2018
1 parent f0204a6 commit 323fc12
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 30 deletions.
16 changes: 2 additions & 14 deletions examples/website/arc/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ class App extends Component {
}
}

componentDidMount() {
window.addEventListener('resize', this._onResize.bind(this));
this._onResize();
}

componentWillReceiveProps(nextProps) {
const arcsChanged =
nextProps.data !== this.props.data ||
Expand All @@ -81,14 +76,6 @@ class App extends Component {
}
}

_onResize() {
const viewState = Object.assign(this.state.viewState, {
width: window.innerWidth,
height: window.innerHeight
});
this._onViewStateChange({viewState});
}

_onViewStateChange({viewState}) {
this.setState({
viewState: {...this.state.viewState, ...viewState}
Expand All @@ -103,7 +90,7 @@ class App extends Component {
// Clicked a county
const selectedCounty = info.object;
this.setState({selectedCounty});
this._recalculateArcs(this.props.data, selectedCounty);
this._recalculateArcs(this.props.data || this.state.counties, selectedCounty);
}

_recalculateArcs(data, selectedFeature) {
Expand Down Expand Up @@ -176,6 +163,7 @@ class App extends Component {
viewState={viewState}
onViewStateChange={onViewStateChange}
controller={MapController}
pickingRadius={10}
>
<StaticMap
viewId="map"
Expand Down
4 changes: 3 additions & 1 deletion examples/website/icon/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class App extends Component {
// the world, we can't use some fixed deltaLon and deltaLat
_updateCluster({data, viewState}) {
const oldViewState = this._oldViewState || {};
const oldData = this._data;
const oldData = this._oldData;
const changed =
data !== oldData ||
viewState.width !== oldViewState.width ||
Expand Down Expand Up @@ -207,6 +207,8 @@ class App extends Component {
mapboxApiAccessToken={mapboxApiAccessToken}
preventStyleDiffing={true}
/>

<div>{this.props.children}</div>
</DeckGL>
);
}
Expand Down
3 changes: 2 additions & 1 deletion modules/react/src/deckgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ export default class DeckGL extends React.Component {
return child;
}

const viewport = this.deck.layerManager.viewManager.getViewport(viewId);
const viewport =
this.deck.layerManager && this.deck.layerManager.viewManager.getViewport(viewId);

// Drop (auto-hide) elements with viewId that are not matched by any current view
if (!viewport) {
Expand Down
30 changes: 16 additions & 14 deletions website/src/components/demos/icon-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export default class IconDemo extends Component {
return;
}

const {viewport, params} = this.props;
const z = Math.floor(viewport.zoom);
const {viewState, params} = this.props;
const z = Math.floor(viewState.zoom);
const showCluster = params.cluster.value;

let hoveredItems = null;
Expand Down Expand Up @@ -159,18 +159,20 @@ export default class IconDemo extends Component {
}

return (
<div className={`icon-demo ${hoveredItems ? 'clickable' : ''}`}>
<App
{...this.props}
data={data[0]}
iconAtlas="images/location-icon-atlas.png"
iconMapping={data[1]}
showCluster={params.cluster.value}
onHover={this._onHover}
onClick={this._onClick} />

{ this._renderhoveredItems() }
</div>
<App
{...this.props}
data={data[0]}
iconAtlas="images/location-icon-atlas.png"
iconMapping={data[1]}
showCluster={params.cluster.value}
onHover={this._onHover}
onClick={this._onClick} >

<div className={`icon-demo ${hoveredItems ? 'clickable' : ''}`}>
{ this._renderhoveredItems() }
</div>

</App>
);
}
}

0 comments on commit 323fc12

Please sign in to comment.