Skip to content

Commit 961306b

Browse files
authored
Merge pull request #244 from OpenSourceOrg/fix/header-shrink-without-flicker-develop
Shrink the header on scroll again, without the flicker
2 parents 784b021 + df39967 commit 961306b

9 files changed

Lines changed: 81 additions & 34 deletions

‎themes/osi/assets/scss/_1_settings.breakpoints.scss‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@ $wrapperPad: 5vw; // duplicates the production Customizer CSS inset on body > .w
4545
$maxPadding: 48px; // duplicates var(--wp--custom--spacing--max-padding)
4646

4747
// header dimensions
48-
$headerInnerHeight: 125px; // .header--inner fixed height; admin-bar offsets come from core's --wp-admin--admin-bar--height
48+
$headerInnerHeight: 125px; // .header--inner at rest; also the spacer that holds its place in the flow
49+
$headerInnerHeightSmall: 90px; // .header--inner once scrolled
4950
$headerLogoWidth: 300px; // logo column width, held constant so the nav never reflows
50-
$headerLogoHeight: 110px;
51-
$headerLogoHeightSmall: 60px; // logo cap once scrolled // logo cap at rest; needs a length, not none, so the shrink can animate
51+
$headerLogoHeight: 110px; // logo cap at rest; needs a length, not none, so the shrink can animate
52+
$headerLogoHeightSmall: 60px; // logo cap once scrolled
53+
$navPad: 2.1rem; // .nav-main vertical padding at rest
54+
$navPadSmall: .55rem; // .nav-main vertical padding once scrolled
5255
$mobileRowHeight: 34px; // mobile accordion row: the caret's 44px tap target centres its glyph on this
5356
$midPadding: 32px; // duplicates var(--wp--custom--spacing--mid-padding);
5457
$smallPadding: 16px; // duplicates var(--wp--custom--spacing--small-padding);

‎themes/osi/assets/scss/_6_components.header.scss‎

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
.header-main {
2-
// position:fixed; // for header scroll
3-
position: sticky;
2+
position: fixed;
43
top: 0;
5-
width: 100%;
4+
left: 0;
5+
right: 0;
66
z-index: 999;
77
.button a {
88
color: inherit;
99
}
1010
}
1111

12-
// offset in both states, or the header drops 32px out from behind the admin bar the
13-
// moment it goes small. Core stops pinning the bar below 601px, where an offset would
14-
// leave a gap once it scrolls away.
12+
.header--spacer {
13+
height: $headerInnerHeight;
14+
}
15+
16+
html {
17+
scroll-padding-top: calc(#{$headerInnerHeight} + var(--wp-admin--admin-bar--height, 0px));
18+
}
19+
1520
.admin-bar .header-main {
16-
@media only screen and (min-width: 601px) {
17-
top: var(--wp-admin--admin-bar--height, 32px);
18-
}
21+
top: var(--wp-admin--admin-bar--height, 32px);
1922
}
2023

2124
.header-main {
@@ -26,6 +29,7 @@
2629
height: $headerInnerHeight;
2730
display: flex;
2831
align-items: center;
32+
transition: height .3s;
2933
@media only screen and (max-width: #{$break-nav - 0.06}) {
3034
background: #fff;
3135
padding: 16px;
@@ -116,7 +120,6 @@
116120
}
117121

118122
@media only screen and (min-width: #{$break-nav}) {
119-
.header--inner,
120123
.header--quicklinks-inner {
121124
// @include clearfix();
122125
padding-left: $maxPadding;
@@ -125,6 +128,17 @@
125128
.header--inner {
126129
border: 0;
127130
position: relative;
131+
padding-left: calc(#{$wrapperPad} + #{$maxPadding});
132+
padding-right: calc(#{$wrapperPad} + #{$maxPadding});
133+
}
134+
.header-main-small {
135+
.header--inner {
136+
height: $headerInnerHeightSmall;
137+
}
138+
.nav-main {
139+
padding-bottom: $navPadSmall;
140+
padding-top: $navPadSmall;
141+
}
128142
}
129143
.header--blog-name {
130144
// hold the column at full-logo width: letting it shrink with the logo hands the
@@ -144,16 +158,14 @@
144158
clear: right;
145159
padding: 0;
146160
}
147-
// full-bleed white: ::after escapes the wrapper inset so the background spans the
148-
// page, which the design asks for whenever the header is white
149161
@mixin header-white-veil( $border: false ) {
150162
&::after {
151163
background-color: $Nwhite;
152164
@if $border {
153165
border-bottom: 1px solid $Nlight;
154166
}
155167
content: '';
156-
inset: 0 (-$wrapperPad);
168+
inset: 0;
157169
position: absolute;
158170
z-index: -1;
159171
}

‎themes/osi/assets/scss/_6_components.mobile-menu.scss‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@
291291
margin-right: $sidebarWidthMid;
292292
overflow: visible;
293293
}
294+
295+
.header-main {
296+
transform: translateX(-$sidebarWidthMid);
297+
}
294298
}
295299

296300
}
@@ -302,6 +306,10 @@
302306
margin-left: -$sidebarWidthSmall;
303307
margin-right: $sidebarWidthSmall;
304308
}
309+
310+
.header-main {
311+
transform: translateX(-$sidebarWidthSmall);
312+
}
305313
}
306314
}
307315

‎themes/osi/assets/scss/_6_components.navigation--subnav.scss‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,13 @@ $chevronDown: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/sv
420420
display: grid;
421421
gap: 0 2.5rem;
422422
grid-template-columns: repeat(2, minmax(0, 1fr));
423-
left: -$wrapperPad;
423+
left: 0;
424424
max-height: none;
425425
max-width: none;
426426
overflow: visible;
427427
opacity: 0;
428428
padding: 2rem calc(#{$wrapperPad} + #{$maxPadding}) 2.5rem;
429-
right: -$wrapperPad;
429+
right: 0;
430430
text-align: left;
431431
top: 100%;
432432
transform: translateY(8px);

‎themes/osi/assets/scss/_6_components.navigation.scss‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ nav {
8585
// Main Nav
8686
.nav-main {
8787
margin-left: auto;
88-
padding: 2.1rem 0;
89-
transition: all 0.8s ease;
88+
padding: $navPad 0;
89+
transition: padding .3s ease;
9090

9191
ul {
9292
list-style: none;

‎themes/osi/header-ai.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,4 @@
6868
</section>
6969
</div>
7070
</header><!-- #masthead -->
71+
<div class="header--spacer" aria-hidden="true"></div>

‎themes/osi/header.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,4 @@
7070
</section>
7171
</div>
7272
</header><!-- #masthead -->
73+
<div class="header--spacer" aria-hidden="true"></div>

‎themes/osi/style.css‎

Lines changed: 35 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎themes/osi/style.css.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)