|
47 | 47 | getFlowrateData,
|
48 | 48 | } from "./utils/mapUtils";
|
49 | 49 |
|
| 50 | + import config from "../config.json"; |
| 51 | +
|
50 | 52 | export let bounds;
|
51 | 53 | export let stateBoundaries;
|
52 | 54 | export let activeNWISSites;
|
|
64 | 66 | ? { lngLat: { lat: +urlParams.get("lat"), lng: +urlParams.get("lng") } }
|
65 | 67 | : null;
|
66 | 68 |
|
67 |
| - const mobileBreakpoint = 700; |
| 69 | + const mobileBreakpoint = config.mobile_breakpoint; |
| 70 | + let windowWidth; |
68 | 71 |
|
69 | 72 | let container;
|
70 | 73 | let map;
|
|
88 | 91 | let phaseJump;
|
89 | 92 |
|
90 | 93 | // Zoom level won't be adjustable on mobile, but it will be set slightly higher to avoid jiterriness
|
91 |
| - const defaultAltitudeMultiplier = |
92 |
| - window.innerWidth < mobileBreakpoint ? 1.1 : 0.9; |
| 94 | + const defaultAltitudeMultiplier = windowWidth < mobileBreakpoint ? 1.1 : 0.9; |
93 | 95 | let altitudeMultiplier = defaultAltitudeMultiplier;
|
94 | 96 | let altitudeChange = false;
|
95 | 97 | let paused = false;
|
|
119 | 121 | container,
|
120 | 122 | style: mapStyle || "mapbox://styles/mapbox/light-v10",
|
121 | 123 | center: [0, 0],
|
122 |
| - minZoom: window.innerWidth > mobileBreakpoint ? 2 : 1.4, |
123 |
| - zoom: window.innerWidth > mobileBreakpoint ? 2.001 : 1.4001, |
| 124 | + minZoom: windowWidth > mobileBreakpoint ? 2 : 1.4, |
| 125 | + zoom: windowWidth > mobileBreakpoint ? 2.001 : 1.4001, |
124 | 126 | projection: "globe",
|
125 | 127 | });
|
126 | 128 |
|
|
158 | 160 | showCompass: true,
|
159 | 161 | visualizePitch: true,
|
160 | 162 | });
|
161 |
| - // if (window.innerWidth > mobileBreakpoint) { |
| 163 | + // if (windowWidth > mobileBreakpoint) { |
162 | 164 | map.addControl(nav, "top-left");
|
163 | 165 | // }
|
164 | 166 |
|
|
195 | 197 | flyTo: false,
|
196 | 198 | });
|
197 | 199 |
|
198 |
| - if (window.innerWidth < mobileBreakpoint) { |
| 200 | + if (windowWidth < mobileBreakpoint) { |
199 | 201 | geocoderControl.setLimit(4);
|
200 | 202 | }
|
201 | 203 |
|
|
211 | 213 | });
|
212 | 214 |
|
213 | 215 | const position =
|
214 |
| - window.innerWidth > mobileBreakpoint ? "top-right" : "bottom-left"; |
| 216 | + windowWidth > mobileBreakpoint ? "top-right" : "bottom-left"; |
215 | 217 | map.addControl(geocoderControl, position);
|
216 | 218 |
|
217 | 219 | return geocoderControl;
|
|
439 | 441 |
|
440 | 442 | // When using the vizState change/return instead of startRun, it displays the overview before automatically starting the run
|
441 | 443 | // We'll do this with a countdown timer on desktop, and just right into it on mobile
|
442 |
| - if (window.innerWidth > mobileBreakpoint) { |
| 444 | + if (windowWidth > mobileBreakpoint) { |
443 | 445 | vizState = "overview";
|
444 | 446 | // map.scrollZoom.enable();
|
445 | 447 | // map.dragPan.enable();
|
|
1042 | 1044 | pitch: 0,
|
1043 | 1045 | padding: 70,
|
1044 | 1046 | maxZoom: 12,
|
1045 |
| - offset: window.innerWidth < mobileBreakpoint ? [0, -20] : [0, 0], // On mobile, the search bar will get in the way so we actually want it a little off center |
| 1047 | + offset: windowWidth < mobileBreakpoint ? [0, -20] : [0, 0], // On mobile, the search bar will get in the way so we actually want it a little off center |
1046 | 1048 | });
|
1047 | 1049 |
|
1048 | 1050 | map.once("moveend", () => {
|
|
1193 | 1195 | // });
|
1194 | 1196 | </script>
|
1195 | 1197 |
|
1196 |
| -<svelte:window on:keydown={handleKeydown} /> |
| 1198 | +<svelte:window on:keydown={handleKeydown} bind:innerWidth={windowWidth} /> |
1197 | 1199 |
|
1198 | 1200 | <div
|
1199 | 1201 | class="map-wrapper"
|
|
1230 | 1232 | {suggestionModalActive}
|
1231 | 1233 | on:hide-suggestion-modal={hideSuggestionModal}
|
1232 | 1234 | />
|
1233 |
| - {#if window.innerWidth > mobileBreakpoint && advancedFeaturesOn === true} |
| 1235 | + {#if windowWidth > mobileBreakpoint && advancedFeaturesOn === true} |
1234 | 1236 | <WaterLevelDisplay
|
1235 | 1237 | {currentFlowrate}
|
1236 | 1238 | {maxFlowrate}
|
|
0 commit comments