@@ -103,11 +103,18 @@ ready(() => {
103
103
// i.e. if there are three circles, this is 50% as the bar's width
104
104
// must increase by 50% to get from the first to second circle, etc
105
105
const increment = 100 / ( circles . length - 1 )
106
- const headerYOffset = ( window . innerHeight ) / 10 - parseFloat ( getComputedStyle ( _ ( "h2" ) ) . fontSize ) - 5
106
+
107
+ let headerYOffset = ( window . innerHeight ) / 10 - parseFloat ( getComputedStyle ( _ ( "h2" ) ) . fontSize ) - 5
107
108
108
109
// Current scroll position
109
110
let scrollPos = 0
110
111
112
+ // fire when window resized, e.g. when device is turned
113
+ window . addEventListener ( 'resize' , function ( event ) {
114
+ intro = _ ( '.content' ) . offsetTop ; // set top of content
115
+ headerYOffset = ( window . innerHeight ) / 10 - parseFloat ( getComputedStyle ( _ ( "h2" ) ) . fontSize ) - 5
116
+ } , true ) ;
117
+
111
118
document . addEventListener ( 'scroll' , ( ) => {
112
119
// Update scroll position on scroll
113
120
scrollPos = window . scrollY
@@ -131,10 +138,6 @@ ready(() => {
131
138
// run every 150ms, put most things-that-change-with-scrolling here.
132
139
// more efficient than putting them in the scroll event
133
140
window . setInterval ( function ( ) {
134
- intro = _ ( '.content' ) . offsetTop ; // set top of content
135
- // ^ this is in a loop so that if the screen is turned it
136
- // will update with new values
137
-
138
141
// if user scrolls below hero, show scroll up button
139
142
if ( scrollPos > intro ) {
140
143
scrollup . classList . add ( "show" )
0 commit comments