File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change
1
+ node_modules
2
+ .DS_Store
Original file line number Diff line number Diff line change 40
40
</ ul >
41
41
</ nav >
42
42
</ aside >
43
-
44
43
< script src ='./side-nav.js '> </ script >
45
44
</ body >
46
45
</ html >
Original file line number Diff line number Diff line change @@ -63,6 +63,9 @@ class SideNav {
63
63
}
64
64
65
65
onTouchMove ( evt ) {
66
+ if ( ! this . touchingSideNav )
67
+ return ;
68
+
66
69
this . currentX = evt . touches [ 0 ] . pageX ;
67
70
const translateX = Math . min ( 0 , this . currentX - this . startX ) ;
68
71
@@ -72,22 +75,24 @@ class SideNav {
72
75
}
73
76
74
77
onTouchEnd ( evt ) {
78
+ if ( ! this . touchingSideNav )
79
+ return ;
80
+
75
81
this . touchingSideNav = false ;
76
82
77
83
const translateX = Math . min ( 0 , this . currentX - this . startX ) ;
78
84
this . sideNavContainerEl . style . transform = '' ;
79
85
80
86
if ( translateX < 0 ) {
81
- this . hideSideNav ( ) ;
87
+ requestAnimationFrame ( this . hideSideNav ) ;
82
88
}
83
89
}
84
90
85
91
update ( ) {
86
- if ( ! this . sideNavEl . classList . contains ( 'side-nav--visible' ) )
92
+ if ( ! this . touchingSideNav )
87
93
return ;
88
94
89
- if ( this . touchingSideNav )
90
- requestAnimationFrame ( this . update ) ;
95
+ requestAnimationFrame ( this . update ) ;
91
96
92
97
const translateX = Math . min ( 0 , this . currentX - this . startX ) ;
93
98
this . sideNavContainerEl . style . transform = `translateX(${ translateX } px)` ;
You can’t perform that action at this time.
0 commit comments