diff options
| author | Georgios Andreadis <info@gandreadis.com> | 2020-07-21 15:33:37 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:48:16 +0200 |
| commit | 912e1b96bfa7d6c022d854fa744f719b49ca98d0 (patch) | |
| tree | 49cdaf109aa08b0149c34174ce0f00c7056221ea /frontend/src/components/app/map/layers/HoverLayerComponent.js | |
| parent | 791b5d1e443f97adc756264878c3aae41ca0f748 (diff) | |
Add first plotting attempts for portfolios
Diffstat (limited to 'frontend/src/components/app/map/layers/HoverLayerComponent.js')
| -rw-r--r-- | frontend/src/components/app/map/layers/HoverLayerComponent.js | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/frontend/src/components/app/map/layers/HoverLayerComponent.js b/frontend/src/components/app/map/layers/HoverLayerComponent.js index 25c9c412..bead87de 100644 --- a/frontend/src/components/app/map/layers/HoverLayerComponent.js +++ b/frontend/src/components/app/map/layers/HoverLayerComponent.js @@ -26,18 +26,13 @@ class HoverLayerComponent extends React.Component { } const positionX = Math.floor( - (this.props.mouseX - this.props.mapPosition.x) / - (this.props.mapScale * TILE_SIZE_IN_PIXELS), + (this.props.mouseX - this.props.mapPosition.x) / (this.props.mapScale * TILE_SIZE_IN_PIXELS) ) const positionY = Math.floor( - (this.props.mouseY - this.props.mapPosition.y) / - (this.props.mapScale * TILE_SIZE_IN_PIXELS), + (this.props.mouseY - this.props.mapPosition.y) / (this.props.mapScale * TILE_SIZE_IN_PIXELS) ) - if ( - positionX !== this.state.positionX || - positionY !== this.state.positionY - ) { + if (positionX !== this.state.positionX || positionY !== this.state.positionY) { this.setState({ positionX, positionY, @@ -48,15 +43,11 @@ class HoverLayerComponent extends React.Component { render() { if (!this.props.isEnabled()) { - return <Layer/> + return <Layer /> } - const pixelX = - this.props.mapScale * this.state.positionX * TILE_SIZE_IN_PIXELS + - this.props.mapPosition.x - const pixelY = - this.props.mapScale * this.state.positionY * TILE_SIZE_IN_PIXELS + - this.props.mapPosition.y + const pixelX = this.props.mapScale * this.state.positionX * TILE_SIZE_IN_PIXELS + this.props.mapPosition.x + const pixelY = this.props.mapScale * this.state.positionY * TILE_SIZE_IN_PIXELS + this.props.mapPosition.y return ( <Layer opacity={0.6}> @@ -66,16 +57,15 @@ class HoverLayerComponent extends React.Component { scale={this.props.mapScale} isValid={this.state.validity} onClick={() => - this.state.validity - ? this.props.onClick(this.state.positionX, this.state.positionY) - : undefined} + this.state.validity ? this.props.onClick(this.state.positionX, this.state.positionY) : undefined + } /> {this.props.children ? React.cloneElement(this.props.children, { - pixelX, - pixelY, - scale: this.props.mapScale, - }) + pixelX, + pixelY, + scale: this.props.mapScale, + }) : undefined} </Layer> ) |
