Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions contextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,8 @@
$q.all($promises).then(function () {
var topCoordinate = event.pageY;
var menuHeight = angular.element($ul[0]).prop('offsetHeight');
var winHeight = $window.scrollY + event.view.innerHeight;
var winHeight = $window.pageYOffset + event.view.innerHeight;

/// the 20 pixels in second condition are considering the browser status bar that sometimes overrides the element
if (topCoordinate > menuHeight && winHeight - topCoordinate < menuHeight + 20) {
topCoordinate = event.pageY - menuHeight;
Expand Down Expand Up @@ -515,7 +516,7 @@
}

function removeAllContextMenus(e) {
$document.find('body').off('mousedown', removeOnOutsideClickEvent);
$document.find('body').off('mousedown touchstart', removeOnOutsideClickEvent);
$document.off('scroll', removeOnScrollEvent);
$(_clickedElement).removeClass('context');
removeContextMenus();
Expand Down Expand Up @@ -573,6 +574,10 @@

angular.forEach(openMenuEvents, function (openMenuEvent) {
element.on(openMenuEvent.trim(), function (event) {
// Cleanup any leftover contextmenus(there are cases with longpress on touch where we
// still see multiple contextmenus)
removeAllContextMenus();

if(!attrs.allowEventPropagation) {
event.stopPropagation();
event.preventDefault();
Expand All @@ -584,7 +589,7 @@
}

// Remove if the user clicks outside
$document.find('body').on('mousedown', removeOnOutsideClickEvent);
$document.find('body').on('mousedown touchstart', removeOnOutsideClickEvent);
// Remove the menu when the scroll moves
$document.on('scroll', removeOnScrollEvent);

Expand Down