Skip to content

Commit 3341038

Browse files
committed
Small fixes
1 parent 5df954f commit 3341038

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.DS_Store

side-nav/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
</ul>
4141
</nav>
4242
</aside>
43-
4443
<script src='./side-nav.js'></script>
4544
</body>
4645
</html>

side-nav/side-nav.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ class SideNav {
6363
}
6464

6565
onTouchMove (evt) {
66+
if (!this.touchingSideNav)
67+
return;
68+
6669
this.currentX = evt.touches[0].pageX;
6770
const translateX = Math.min(0, this.currentX - this.startX);
6871

@@ -72,22 +75,24 @@ class SideNav {
7275
}
7376

7477
onTouchEnd (evt) {
78+
if (!this.touchingSideNav)
79+
return;
80+
7581
this.touchingSideNav = false;
7682

7783
const translateX = Math.min(0, this.currentX - this.startX);
7884
this.sideNavContainerEl.style.transform = '';
7985

8086
if (translateX < 0) {
81-
this.hideSideNav();
87+
requestAnimationFrame(this.hideSideNav);
8288
}
8389
}
8490

8591
update () {
86-
if (!this.sideNavEl.classList.contains('side-nav--visible'))
92+
if (!this.touchingSideNav)
8793
return;
8894

89-
if (this.touchingSideNav)
90-
requestAnimationFrame(this.update);
95+
requestAnimationFrame(this.update);
9196

9297
const translateX = Math.min(0, this.currentX - this.startX);
9398
this.sideNavContainerEl.style.transform = `translateX(${translateX}px)`;

0 commit comments

Comments
 (0)