|
386 | 386 | $q.all($promises).then(function () { |
387 | 387 | var topCoordinate = event.pageY; |
388 | 388 | var menuHeight = angular.element($ul[0]).prop('offsetHeight'); |
389 | | - var winHeight = $window.scrollY + event.view.innerHeight; |
| 389 | + var winHeight = $window.pageYOffset + event.view.innerHeight; |
| 390 | + |
390 | 391 | /// the 20 pixels in second condition are considering the browser status bar that sometimes overrides the element |
391 | 392 | if (topCoordinate > menuHeight && winHeight - topCoordinate < menuHeight + 20) { |
392 | 393 | topCoordinate = event.pageY - menuHeight; |
|
515 | 516 | } |
516 | 517 |
|
517 | 518 | function removeAllContextMenus(e) { |
518 | | - $document.find('body').off('mousedown', removeOnOutsideClickEvent); |
| 519 | + $document.find('body').off('mousedown touchstart', removeOnOutsideClickEvent); |
519 | 520 | $document.off('scroll', removeOnScrollEvent); |
520 | 521 | $(_clickedElement).removeClass('context'); |
521 | 522 | removeContextMenus(); |
|
573 | 574 |
|
574 | 575 | angular.forEach(openMenuEvents, function (openMenuEvent) { |
575 | 576 | element.on(openMenuEvent.trim(), function (event) { |
| 577 | + // Cleanup any leftover contextmenus(there are cases with longpress on touch where we |
| 578 | + // still see multiple contextmenus) |
| 579 | + removeAllContextMenus(); |
| 580 | + |
576 | 581 | if(!attrs.allowEventPropagation) { |
577 | 582 | event.stopPropagation(); |
578 | 583 | event.preventDefault(); |
|
584 | 589 | } |
585 | 590 |
|
586 | 591 | // Remove if the user clicks outside |
587 | | - $document.find('body').on('mousedown', removeOnOutsideClickEvent); |
| 592 | + $document.find('body').on('mousedown touchstart', removeOnOutsideClickEvent); |
588 | 593 | // Remove the menu when the scroll moves |
589 | 594 | $document.on('scroll', removeOnScrollEvent); |
590 | 595 |
|
|
0 commit comments