Skip to content

Commit 49b82e8

Browse files
committed
various bugfixes
1 parent 70ae358 commit 49b82e8

File tree

7 files changed

+46
-28
lines changed

7 files changed

+46
-28
lines changed

amp-pwa-reader/css/config.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
:root {
22
--header-height: 60px;
3-
--animation-speed: 0.3s;
3+
--animation-speed: 3s;
44
}

amp-pwa-reader/css/header.css

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ header svg {
1818
margin-top: 6px;
1919
}
2020

21-
label[for="nav-trigger"] {
22-
/* critical positioning styles */
21+
.hamburger {
2322
position: absolute;
2423
z-index: 2;
25-
2624
border: 0;
2725
outline: none;
2826
border-radius: 50%;
@@ -32,6 +30,8 @@ label[for="nav-trigger"] {
3230
left: 1em;
3331
top: auto;
3432
box-shadow: 0 0 0 0.0625rem rgba(0,0,0,0.08);
33+
padding: 15px 15px;
34+
display: inline-block;
3535
}
3636

3737
/*!
@@ -42,19 +42,15 @@ label[for="nav-trigger"] {
4242
* @link https://github.com/jonsuh/hamburgers
4343
*/
4444
.hamburger {
45-
padding: 15px 15px;
46-
display: inline-block;
47-
cursor: pointer;
4845
transition-property: opacity, filter;
4946
transition-duration: var(--animation-speed);
5047
transition-timing-function: linear;
5148
font: inherit;
5249
color: inherit;
5350
text-transform: none;
54-
background-color: transparent;
55-
border: 0;
5651
margin: 0;
57-
overflow: visible;}
52+
overflow: visible;
53+
}
5854

5955
.hamburger-box {
6056
width: 32px;
@@ -88,9 +84,9 @@ label[for="nav-trigger"] {
8884
* Arrow
8985
*/
9086
.article-shown .hamburger .hamburger-inner::before,
91-
#nav-trigger:checked ~ header .hamburger .hamburger-inner::before {
87+
.nav-shown .hamburger .hamburger-inner::before {
9288
transform: translate3d(-8px, 3px, 0) rotate(-45deg) scale(0.7, 1); }
9389

9490
.article-shown .hamburger .hamburger-inner::after,
95-
#nav-trigger:checked ~ header .hamburger .hamburger-inner::after {
91+
.nav-shown .hamburger .hamburger-inner::after {
9692
transform: translate3d(-8px, -3px, 0) rotate(45deg) scale(0.7, 1); }

amp-pwa-reader/css/main.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,5 @@ body {
3636

3737
main {
3838
line-height: 1.4;
39-
4039
}
4140

amp-pwa-reader/css/nav.css

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
width: 80vw;
44
height: 100vh;
55
max-width: 200px;
6-
position: absolute;
6+
position: fixed;
77
top: var(--header-height);
88
left: 0;
99
transform: translateX(-100%);
@@ -39,24 +39,18 @@
3939
background: linear-gradient(135deg, rgba(64, 117, 199, 0.1) 0%,rgba(13, 71, 161, 0.37) 100%);
4040
}
4141

42-
/* Nav Trigger */
43-
#nav-trigger {
44-
position: absolute;
45-
clip: rect(0, 0, 0, 0);
46-
}
47-
4842
header,
4943
main,
5044
.category,
5145
.navigation {
5246
transition: transform var(--animation-speed);
5347
}
5448

55-
#nav-trigger:checked ~ .category,
56-
#nav-trigger:checked ~ main {
49+
.nav-shown .category,
50+
.nav-shown main {
5751
transform: translateX(200px);
5852
}
5953

60-
#nav-trigger:checked ~ .navigation {
54+
.nav-shown .navigation {
6155
transform: translateX(0);
6256
}

amp-pwa-reader/index.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@
1919

2020
<div class="wrapper">
2121

22-
<input type="checkbox" id="nav-trigger" />
23-
2422
<header>
2523

26-
<label for="nav-trigger" class="hamburger">
24+
<button class="hamburger">
2725
<span class="hamburger-box">
2826
<span class="hamburger-inner"></span>
2927
</span>
30-
</label>
28+
</button>
3129

3230
<svg width="160" height="30" viewBox="0 0 320 60" class="new-header__logo__svg inline-guardian-logo-160__svg inline-logo__svg">
3331
<path fill="#fff" d="M284 45h16v-3l-3-1.5v-20c1.2-.9 2.8-1.1 4.3-1.1 2.8 0 3.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10.4 9.3 0 5.1 3.5 8.7 8.3 8.7 3.8 0 7.4-1.7 8.7-4.4h.3c.5 3.3 3.3 4.4 6.4 4.4 2.4 0 4.8-.6 5.7-1.6v-2l-3-1.5v-18c0-6.9-5-9.4-13.1-9.4-5.3 0-8.8 1.4-11.6 2.7v7.8h4.7l2-6c.8-.5 2.3-.5 2.8-.5zm2.2 22.9c-1.9 0-4-1.1-4-4.6 0-2.4 2.4-4.6 4.8-5l2.2-.5v8.5s-1.9 1.6-3 1.6zm-138.7 5.6c.4 0 .9 0 1.3-.1 3.5-.3 6.7-2 8.4-4.2v4.1l12-1.5v-2l-3-2V13h-1l-11.9 2.3v2.8l3.9 1.6V38c-1.1.8-2.4 1.3-4.2 1.3-2.5 0-4.8-.8-4.8-4.3V13h-1l-12 2.5v2.6l4 1.6V36c0 5.4 2.2 9.7 8.3 9.7zM96 38c-1.2 0-2.5-.8-2.5-1.9 0-.8.6-1.7 1.3-2.3 1.6.5 3 .6 5 .6 7.8 0 13.2-3.7 13.2-10.4 0-3-1.3-4.6-3.2-6.4L115 19v-6l-8.2 1.6c-1.9-.7-4.5-1.6-7-1.6-7.8 0-13.2 4.1-13.2 10.8 0 4.1 2 7.1 5 8.8l.3.2c-1.7 1.2-5.3 4-5.3 7.2 0 2.4 1.5 4.8 4.8 5.5C88 46.3 84 48 84 52c0 4.1 5.9 8 15.5 8 11.8 0 16.5-5.7 16.5-13 0-6.1-2.8-9-9.5-9H96zm7.5-14c0 5.7-1.3 6.5-3.5 6.5s-4-.8-4-6.5c0-5.8 1.8-7.5 4-7.5s3.5 2 3.5 7.5zM92 50.9c.1-1.5 1.1-3.4 3.7-3.6h8.6c2.5 0 3.7 2 3.7 3.6 0 3.2-2 4.4-8.3 4.4-5.5 0-7.8-2.2-7.7-4.4z"></path>

amp-pwa-reader/js/Article.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ class Article {
133133
// add class to html element for global CSS stuff
134134
document.documentElement.classList.add('article-shown');
135135

136+
this.takeoverScroll();
137+
136138
// Set the visibility state of the AMP doc to visible
137139
this.ampDoc.setVisibilityState('visible');
138140

@@ -149,6 +151,8 @@ class Article {
149151
// remove class to html element for global CSS stuff
150152
document.documentElement.classList.remove('article-shown');
151153

154+
this.restoreScroll();
155+
152156
// Show the card header
153157
this.card.elem.style.opacity = '1';
154158

@@ -157,11 +161,22 @@ class Article {
157161

158162
return new Promise((resolve, reject) => {
159163
this.animateOut().onfinish = () => {
164+
160165
this.clear();
161166
resolve();
162167
};
163168
});
164169

165170
}
166171

172+
takeoverScroll() {
173+
this._mainScrollY = document.scrollingElement.scrollTop;
174+
document.scrollingElement.scrollTop = 0;
175+
this.container.style.transform = '';
176+
}
177+
178+
restoreScroll() {
179+
document.scrollingElement.scrollTop = this._mainScrollY;
180+
}
181+
167182
}

amp-pwa-reader/js/Nav.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ class Nav {
6060
}));
6161
}
6262

63+
// reset scroll position
64+
document.scrollingElement.scrollTop = 0;
65+
6366
});
6467

6568
}
@@ -68,12 +71,25 @@ class Nav {
6871
return document.querySelector('.navigation a[data-tag="' + category + '"]');
6972
}
7073

74+
show() {
75+
document.body.classList.add('nav-shown');
76+
}
77+
7178
hide() {
72-
document.getElementById('nav-trigger').checked = false;
79+
document.body.classList.remove('nav-shown');
80+
}
81+
82+
toggle() {
83+
return this[document.body.classList.contains('nav-shown') ? 'hide' : 'show']();
7384
}
7485

7586
bind() {
7687

88+
document.querySelector('.hamburger').addEventListener('click', event => {
89+
this.toggle();
90+
event.preventDefault();
91+
}), false;
92+
7793
document.querySelector('.navigation').addEventListener('click', event => {
7894
event.target.nodeName === 'A' && this.navigate(event.target.dataset.tag, event.target.parentNode);
7995
event.preventDefault();

0 commit comments

Comments
 (0)