diff --git a/_includes/nav.html b/_includes/nav.html
index 6ce7d944514..f50ac936a1f 100644
--- a/_includes/nav.html
+++ b/_includes/nav.html
@@ -42,7 +42,7 @@
var __HuxNav__ = {
close: function(){
- $navbar.className = " ";
+ $navbar.className = " ";
// wait until animation end.
setTimeout(function(){
// prevent frequently toggle
@@ -66,17 +66,25 @@
}
})
- $toggle.addEventListener('touchstart', function(e){
- // stop propagating event to document.
- e.stopPropagation();
- })
-
+ /**
+ * Stop 'touchstart' from $collapse propagating to document
+ */
$collapse.addEventListener('touchstart', function(e){
- // stop propagating event to document.
e.stopPropagation();
})
+ /**
+ * Since Fastclick is used to delegate 'touchstart' globally
+ * to hack 300ms delay in iOS by performing a fake 'click',
+ * Using 'e.stopPropagation' to stop 'touchstart' event from
+ * $toggle will break global delegation.
+ *
+ * Instead, we use a 'e.target' filter to prevent handler
+ * added to document close HuxNav.
+ */
document.addEventListener('touchstart', function(e){
+ if(e.target == $toggle) return;
+ if(e.target.className == 'icon-bar') return;
__HuxNav__.close();
})