@@ -85,6 +85,9 @@ var // currently active contextMenu trigger
85
85
autoHide : false ,
86
86
// ms to wait before showing a hover-triggered context menu
87
87
delay : 200 ,
88
+ // flag denoting if a second trigger should simply move (true) or rebuild (false) an open menu
89
+ // as long as the trigger happened on one of the trigger-element's child nodes
90
+ reposition : true ,
88
91
// determine position to show menu at
89
92
determinePosition : function ( $menu ) {
90
93
// position to the lower middle of the trigger element
@@ -352,13 +355,16 @@ var // currently active contextMenu trigger
352
355
353
356
setTimeout ( function ( ) {
354
357
var $window , hideshow , possibleTarget ;
355
- // test if we need to reposition the menu
356
- if ( ( root . trigger == 'left' && button == 0 ) || ( root . trigger == 'right' && button == 2 ) ) {
358
+
359
+ // find the element that would've been clicked, wasn't the layer in the way
360
+ if ( document . elementFromPoint ) {
361
+ root . $layer . hide ( ) ;
362
+ target = document . elementFromPoint ( x - $win . scrollLeft ( ) , y - $win . scrollTop ( ) ) ;
363
+ root . $layer . show ( ) ;
364
+ }
365
+
366
+ if ( root . reposition && ( ( root . trigger == 'left' && button == 0 ) || ( root . trigger == 'right' && button == 2 ) ) ) {
357
367
if ( document . elementFromPoint ) {
358
- root . $layer . hide ( ) ;
359
- target = document . elementFromPoint ( x - $win . scrollLeft ( ) , y - $win . scrollTop ( ) ) ;
360
- root . $layer . show ( ) ;
361
-
362
368
if ( root . $trigger . is ( target ) || root . $trigger . has ( target ) . length ) {
363
369
root . position . call ( root . $trigger , root , x , y ) ;
364
370
return ;
@@ -385,9 +391,8 @@ var // currently active contextMenu trigger
385
391
}
386
392
}
387
393
}
388
-
389
- if ( target && target . length ) {
390
- target . contextMenu ( { x : x , y : y } ) ;
394
+ if ( target ) {
395
+ $ ( target ) . contextMenu ( { x : x , y : y } ) ;
391
396
} else {
392
397
// TODO: it would be nice if we could prevent animations here
393
398
root . $menu . trigger ( 'contextmenu:hide' ) ;
0 commit comments