Skip to content

Commit 9224812

Browse files
Merge pull request #46 from hcorson-dosch-usgs/fix_mobile_issues
Fix mobile issues
2 parents 29b77d1 + 3f3932c commit 9224812

File tree

4 files changed

+54
-19
lines changed

4 files changed

+54
-19
lines changed

src/App.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ h2{
125125
color: $textcolor;
126126
@media screen and (max-width: 600px) {
127127
font-size: 4rem;
128+
line-height: 1.1;
128129
}
129130
}
130131
h3{

src/assets/text/droughtAnnotations_mobile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default {
106106
{
107107
id: '1980s_2',
108108
date: '1990-02-15',
109-
text: 'In the summer of 1988, streamflow in the Mississippi River was so low that barges could not go up and down the lower section of the river. That same summer, wildfires burned 36% of Yellowstone National Park, triggering the largest fire-fighting effort in the U.S. at that time.',
109+
text: 'In the summer of 1988, streamflow in the Mississippi River was so low that barges could not go up and down the lower section of the river. That same summer, wildfires burned 36% of Yellowstone National Park, triggering the largest wildland fire-fighting effort in the U.S. up to that time.',
110110
mobile_x_offset_per: 80
111111
},
112112
{

src/assets/text/droughtNarrations_desktop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export default {
9797
title: '1980s Drought (1987 - 1992)',
9898
start_date: '1990-10-31',
9999
end_date: '1994-10-31',
100-
text: 'In the summer of 1988, streamflow in the Mississippi River was so low that barges could not go up and down the lower section of the river. That same summer, wildfires burned 36% of Yellowstone National Park, triggering the largest fire-fighting effort in the U.S. at that time. ',
100+
text: 'In the summer of 1988, streamflow in the Mississippi River was so low that barges could not go up and down the lower section of the river. That same summer, wildfires burned 36% of Yellowstone National Park, triggering the largest wildland fire-fighting effort in the U.S. up to that time.',
101101
quote: 'The 1988 drought dramatically illustrates how quickly several years of excess precipitation can change to widespread drought.',
102102
quote_source: '<a href="https://files.dnr.state.mn.us/natural_resources/climate/summaries_and_publications/drought1988.pdf" target="_blank">Minnesota Department of Natural Resources, Division of Waters, 1989</a>',
103103
img_source: 'drought_period_stations_1987.png',

src/components/DroughtHistory.vue

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
<h2>Five droughts that changed history</h2>
66
</div>
77
<div id="intro-container">
8-
<p>
8+
<p
9+
v-if="!mobileView"
10+
>
911
The U.S. has experienced thousands of droughts that have caused water-related problems for humans and ecosystems. But in the last 100 years, five major drought events stand out in their effects on agriculture, wildfires, and streamflow (<a
1012
href="https://doi.org/10.1002/joc.7904"
1113
target="_blank"
@@ -14,6 +16,17 @@
1416
target="_blank"
1517
>USGS Streamgage Network</a>) across the lower 48 states.
1618
</p>
19+
<p
20+
v-if="mobileView"
21+
>
22+
The U.S. has experienced thousands of droughts. But in the last 100 years, five major drought events stand out in their effects on agriculture, wildfires, and streamflow (<a
23+
href="https://doi.org/10.1002/joc.7904"
24+
target="_blank"
25+
>McCabe et al. 2022</a>). Scroll through the timeline to see when and where these major droughts occurred at <a
26+
href="https://dashboard.waterdata.usgs.gov/"
27+
target="_blank"
28+
>USGS streamgages</a> across the lower 48 states.
29+
</p>
1730
</div>
1831
<nav id="nav-button-container">
1932
<p>
@@ -71,7 +84,7 @@
7184
<div
7285
v-for="narration in narrations"
7386
:id="`drought-text-${narration.id}`"
74-
:key="narration.id"
87+
:key="`quote-${narration.id}`"
7588
class="droughtQuote hidden"
7689
>
7790
<p v-html="narration.quote" />
@@ -113,7 +126,7 @@
113126
<img
114127
v-for="narration in narrations"
115128
:id="`inset-map-${narration.id}`"
116-
:key="narration.id"
129+
:key="`map-${narration.id}`"
117130
class="inset-map drought-specific hide"
118131
:src="require(`@/assets/images/${narration.img_source}`)"
119132
:alt="`Map of drought sites in the continental United States. Sites actively in drought during the ${narration.title} are highlighted in red`"
@@ -123,28 +136,35 @@
123136
<div
124137
v-for="narration in narrations"
125138
:id="`drought-text-${narration.id}`"
126-
:key="narration.id"
139+
:key="`title-${narration.id}`"
127140
class="droughtText droughtTitle hidden"
128141
>
129142
<p v-html="narration.title" />
130143
</div>
131144
<div
132145
v-for="narration in narrations"
133146
:id="`drought-text-${narration.id}`"
134-
:key="narration.id"
147+
:key="`text-${narration.id}`"
135148
class="droughtText narration hidden"
136149
>
137150
<p v-html="narration.text" />
138151
</div>
139152
</div>
140153
</section>
141-
<hr>
154+
<hr
155+
v-if="mobileView"
156+
>
142157
<section
143158
id="region-container"
144159
class="page-section"
145160
>
146161
<h3>Drought in Regions of the Conterminous U.S.</h3>
147-
<p>Droughts happen in every region of the U.S. These charts show the same 2000 drought events as the national timeline above, but now they are shown by region. Where the orange violin-like shapes are wider, more streamgages were in drought at one time in that region.</p>
162+
<p>
163+
Droughts happen in every region of the U.S. These charts show the same 2000 drought events as the national timeline above, but now they are shown by <a
164+
href="https://www.usgs.gov/programs/climate-adaptation-science-centers"
165+
target="_blank"
166+
>Climate Adaptation Science Center</a> regions. Where the orange violin-like shapes are wider, more streamgages were in drought at one time in that region.
167+
</p>
148168
<div id="region-grid-container">
149169
<cascMap
150170
v-if="mobileView"
@@ -154,7 +174,7 @@
154174
v-if="mobileView"
155175
id="chart-instructions"
156176
>
157-
Click on the map to explore drought histories in each region
177+
Tap on the map to explore drought histories in each region
158178
</p>
159179
<img
160180
v-if="!mobileView"
@@ -360,7 +380,7 @@ export default {
360380
// dimensions
361381
overlayWidth: null,
362382
overlayHeight: null,
363-
overlayTopMargin: 2,
383+
overlayTopMargin: 3,
364384
// source for regional map
365385
regionMapFilename: "casc_regions_map",
366386
regionDescriptions: regionDroughtDescriptions.regionDescriptions,
@@ -420,7 +440,9 @@ export default {
420440
const scrollLength = scrollDistance/scrollSpeed;
421441
422442
// scroll to position of specified drought
423-
this.$gsap.to(window, {duration: scrollLength, scrollTo: {y: "#scrollStop-" + scrollDroughtYear, offsetY: 100}});
443+
// set vertical scroll offset based on device and window height
444+
const scrollOffset = this.mobileView ? window.innerHeight*0.47: window.innerHeight*0.6;
445+
this.$gsap.to(window, {duration: scrollLength, scrollTo: {y: "#scrollStop-" + scrollDroughtYear, offsetY: scrollOffset}});
424446
},
425447
addOverlay() {
426448
const self = this;
@@ -448,7 +470,7 @@ export default {
448470
this.overlayWidth = window.innerWidth*0.65 //MUST MATCH max-width of grid, which controls chart image width
449471
this.overlayHeight = this.overlayWidth*10 //Based on image aspect ratio
450472
this.svgChartDynamic
451-
.attr("viewBox", "0 0 " + this.overlayWidth + " " + this.overlayHeight)
473+
.attr("viewBox", "0 0 " + this.overlayWidth + " " + (this.overlayHeight + this.overlayTopMargin))
452474
.attr("preserveAspectRatio", "xMidYMid meet")
453475
.attr("width", '100%')
454476
@@ -465,7 +487,7 @@ export default {
465487
.range([0, this.overlayHeight]);
466488
467489
// set y-axis offset
468-
const yAxisOffset = this.mobileView ? 40: 45;
490+
const yAxisOffset = this.mobileView ? 30: 45;
469491
470492
// Set up linear scale for chart width
471493
const xScale = this.d3.scaleLinear()
@@ -627,7 +649,7 @@ export default {
627649
markers: false,
628650
trigger: `#${scrollIDFull}`,
629651
start: "top 50%",
630-
end: 'bottom 50%',
652+
end: 'bottom 40%',
631653
toggleClass: {targets: `#button-${scrollID}`, className: "currentButton"}, // adds class to target when triggered
632654
toggleActions: "restart reverse none reverse"
633655
},
@@ -723,7 +745,7 @@ export default {
723745
markers: false,
724746
trigger: `#${scrollIDFull}`,
725747
start: "top 67%",
726-
end: 'bottom 67%',
748+
end: 'bottom 50%',
727749
toggleClass: {targets: `#button-${scrollID}`, className: "currentButton"}, // adds class to target when triggered
728750
toggleActions: "restart reverse none reverse"
729751
},
@@ -1000,6 +1022,7 @@ $writeFont: 'Edu TAS Beginner', cursive;
10001022
max-width: 90vw;
10011023
min-width: 90vw;
10021024
@media screen and (max-width: 600px) {
1025+
padding: 0px 0 20px 0;
10031026
grid-template-columns: 100%;
10041027
grid-template-rows: max-content max-content max-content max-content max-content;
10051028
grid-template-areas:
@@ -1016,6 +1039,9 @@ $writeFont: 'Edu TAS Beginner', cursive;
10161039
#intro-container {
10171040
grid-area: intro;
10181041
padding: 5px 0px 5px 5px;
1042+
@media screen and (max-width: 600px) {
1043+
padding: 1px 0px 0px 5px;
1044+
}
10191045
}
10201046
#nav-button-container {
10211047
grid-area: buttons;
@@ -1024,6 +1050,9 @@ $writeFont: 'Edu TAS Beginner', cursive;
10241050
padding: 10px 0px 10px 0px;
10251051
z-index: 20;
10261052
background-color: white;
1053+
@media screen and (max-width: 600px) {
1054+
padding: 5px 0px 10px 0px;
1055+
}
10271056
}
10281057
.scrollButton {
10291058
padding: 3px 6px 4px 5px;
@@ -1045,7 +1074,8 @@ $writeFont: 'Edu TAS Beginner', cursive;
10451074
border-color: darkgrey;
10461075
font-weight: bold;
10471076
@media only screen and (max-width: 800px){
1048-
border-color: white
1077+
background-color: darkgrey;
1078+
color: white;
10491079
}
10501080
}
10511081
.scrollButton:focus {
@@ -1212,15 +1242,13 @@ $writeFont: 'Edu TAS Beginner', cursive;
12121242
.droughtText {
12131243
z-index: 10;
12141244
font-weight: 400;
1215-
font-size: 2.0rem;
12161245
-webkit-user-select: none; /* Safari */
12171246
-ms-user-select: none; /* IE 10 and IE 11 */
12181247
user-select: none; /* Standard syntax */
12191248
}
12201249
.droughtText.mobile {
12211250
z-index: 10;
12221251
font-weight: 500;
1223-
font-size: 1.8rem;
12241252
margin: 0 5vw 0 5vw;
12251253
position: absolute;
12261254
}
@@ -1276,6 +1304,9 @@ $writeFont: 'Edu TAS Beginner', cursive;
12761304
.currentButton:hover {
12771305
background-color: darkgrey;
12781306
color: white;
1307+
@media screen and (max-width: 600px) {
1308+
background-color: black;
1309+
}
12791310
}
12801311
#filter-svg {
12811312
width: 0;
@@ -1346,6 +1377,9 @@ $writeFont: 'Edu TAS Beginner', cursive;
13461377
display: flex;
13471378
justify-content: start;
13481379
align-items: center;
1380+
@media screen and (max-width: 600px) {
1381+
justify-content: center;
1382+
}
13491383
}
13501384
.violin-chart {
13511385
transform: rotate(180deg);

0 commit comments

Comments
 (0)