Skip to content

Commit 932df81

Browse files
committed
fix: Identify and stop the correct transition when multiple are fired
1 parent 61a097f commit 932df81

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

side-nav/side-nav.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ class SideNav {
4141
this.currentX = 0;
4242
this.touchingSideNav = false;
4343

44+
this.transitionEndProperty = null;
45+
this.transitionEndTime = 0;
46+
4447
this.supportsPassive = undefined;
4548
this.addEventListeners();
4649
}
@@ -119,6 +122,13 @@ class SideNav {
119122
}
120123

121124
onTransitionEnd (evt) {
125+
if (evt.propertyName != this.transitionEndProperty && evt.elapsedTime!= this.transitionEndTime){
126+
return;
127+
}
128+
129+
this.transitionEndProperty = null;
130+
this.transitionEndTime = 0;
131+
122132
this.sideNavEl.classList.remove('side-nav--animatable');
123133
this.sideNavEl.removeEventListener('transitionend', this.onTransitionEnd);
124134
}
@@ -127,13 +137,22 @@ class SideNav {
127137
this.sideNavEl.classList.add('side-nav--animatable');
128138
this.sideNavEl.classList.add('side-nav--visible');
129139
this.detabinator.inert = false;
140+
141+
this.transitionEndProperty = 'transform';
142+
// the duration of transition (make unique to distinguish transitions )
143+
this.transitionEndTime = 0.33;
144+
130145
this.sideNavEl.addEventListener('transitionend', this.onTransitionEnd);
131146
}
132147

133148
hideSideNav () {
134149
this.sideNavEl.classList.add('side-nav--animatable');
135150
this.sideNavEl.classList.remove('side-nav--visible');
136151
this.detabinator.inert = true;
152+
153+
this.transitionEndProperty = 'transform';
154+
this.transitionEndTime = 0.13;
155+
137156
this.sideNavEl.addEventListener('transitionend', this.onTransitionEnd);
138157
}
139158
}

0 commit comments

Comments
 (0)