File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ class SideNav {
31
31
this . onTouchMove = this . onTouchMove . bind ( this ) ;
32
32
this . onTouchEnd = this . onTouchEnd . bind ( this ) ;
33
33
this . onTransitionEnd = this . onTransitionEnd . bind ( this ) ;
34
+ this . update = this . update . bind ( this ) ;
34
35
35
36
this . startX = 0 ;
36
37
this . currentX = 0 ;
@@ -55,6 +56,8 @@ class SideNav {
55
56
56
57
this . startX = evt . touches [ 0 ] . pageX ;
57
58
this . currentX = this . startX ;
59
+
60
+ requestAnimationFrame ( this . update ) ;
58
61
}
59
62
60
63
onTouchMove ( evt ) {
@@ -64,8 +67,6 @@ class SideNav {
64
67
if ( translateX < 0 ) {
65
68
evt . preventDefault ( ) ;
66
69
}
67
-
68
- this . sideNavContainerEl . style . transform = `translateX(${ translateX } px)` ;
69
70
}
70
71
71
72
onTouchEnd ( evt ) {
@@ -77,6 +78,16 @@ class SideNav {
77
78
}
78
79
}
79
80
81
+ update ( ) {
82
+ if ( ! this . sideNavEl . classList . contains ( 'side-nav--visible' ) )
83
+ return ;
84
+
85
+ requestAnimationFrame ( this . update ) ;
86
+
87
+ const translateX = Math . min ( 0 , this . currentX - this . startX ) ;
88
+ this . sideNavContainerEl . style . transform = `translateX(${ translateX } px)` ;
89
+ }
90
+
80
91
blockClicks ( evt ) {
81
92
evt . stopPropagation ( ) ;
82
93
}
You can’t perform that action at this time.
0 commit comments