diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-22 21:20:54 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 10:06:18 +0200 |
| commit | bf7708f658cc6299a3b775afe24459b5a808c54d (patch) | |
| tree | 227520267968759e2a2f1e29e6f3edfeb4e3cf8a /src/components/app/map/controls/ZoomControlComponent.js | |
| parent | e722cf117d0e3ebac20237f96764fb08cab49a62 (diff) | |
Restructure component and container directories
Diffstat (limited to 'src/components/app/map/controls/ZoomControlComponent.js')
| -rw-r--r-- | src/components/app/map/controls/ZoomControlComponent.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/components/app/map/controls/ZoomControlComponent.js b/src/components/app/map/controls/ZoomControlComponent.js new file mode 100644 index 00000000..c5628d16 --- /dev/null +++ b/src/components/app/map/controls/ZoomControlComponent.js @@ -0,0 +1,31 @@ +import React from "react"; +import {MAP_MAX_SCALE, MAP_MIN_SCALE, MAP_SCALE_PER_EVENT} from "../MapConstants"; + +const ZoomControlComponent = ({mapScale, setMapScale}) => { + const zoom = (out) => { + const newScale = out ? mapScale / MAP_SCALE_PER_EVENT : mapScale * MAP_SCALE_PER_EVENT; + const boundedScale = Math.min(Math.max(MAP_MIN_SCALE, newScale), MAP_MAX_SCALE); + setMapScale(boundedScale); + }; + + return ( + <span> + <button + className="btn btn-default btn-circle btn-sm mr-1" + title="Zoom in" + onClick={() => zoom(false)} + > + <span className="fa fa-plus"/> + </button> + <button + className="btn btn-default btn-circle btn-sm mr-1" + title="Zoom out" + onClick={() => zoom(true)} + > + <span className="fa fa-minus"/> + </button> + </span> + ); +}; + +export default ZoomControlComponent; |
