Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Commit

Permalink
touch timing fix - extra measure that'll help with some touch impleme…
Browse files Browse the repository at this point in the history
…ntations
  • Loading branch information
scottjehl committed Aug 9, 2016
1 parent 917663b commit 1b2d7b1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/collapsible.menu.js
Expand Up @@ -63,6 +63,7 @@
var startedByTouch = false;
var hover = $collapsible.is( "[data-collapsible-hover]" );
var exclusiveHover = $collapsible.is( "[data-collapsible-hover='exclusive']" );
var mouseovertimestamp = 0;

if( hover ){
if( exclusiveHover ){
Expand All @@ -81,6 +82,7 @@
} )
// mouseover covers child collapsibles in a more friendly way than mouseleave
.bind( "mouseover." + pluginName, function( e ){
mouseovertimestamp = new Date().getTime();
if( !startedByTouch && isMenu() && $( e.target ).closest( self.header ).length ){
$collapsible.data( pluginName ).expand();
}
Expand All @@ -92,8 +94,9 @@
} )
// make hover menu header links click-through for mouse, though not for touch
.bind( "click", function( e ){

if( $( e.target ).is( self.header ) && isMenu() && $( e.target ).is( "a[href]" ) && !startedByTouch ){
var timesincemouseover = new Date().getTime() - mouseovertimestamp;
alert(timesincemouseover);
if( $( e.target ).is( self.header ) && isMenu() && $( e.target ).is( "a[href]" ) && !startedByTouch && timesincemouseover > 300 ){
window.location.href = e.target.href;
}
} );
Expand Down

0 comments on commit 1b2d7b1

Please sign in to comment.