Skip to content

Commit

Permalink
[v1.6 alpha] all right, I thought this is final fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Huxpro committed Jan 17, 2016
1 parent b464bf8 commit 130f244
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions _includes/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

var __HuxNav__ = {
close: function(){
$navbar.className = " ";
$navbar.className = " ";
// wait until animation end.
setTimeout(function(){
// prevent frequently toggle
Expand All @@ -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();
})
</script>

0 comments on commit 130f244

Please sign in to comment.