Skip to content

Commit

Permalink
Merge pull request mozilla-b2g#7324 from crdlc/bug-827331
Browse files Browse the repository at this point in the history
Bug 827331 - Long press is fired while slow panning (about contextmenu e...
  • Loading branch information
vingtetun committed Jan 9, 2013
2 parents 3c3c104 + f08c266 commit 6eaab8f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apps/homescreen/js/grid.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ const GridManager = (function() {
right: 0 right: 0
}; };


var startEvent, isPanning = false; var startEvent, isPanning = false, deltaX;


function handleEvent(evt) { function handleEvent(evt) {
switch (evt.type) { switch (evt.type) {
case 'mousedown': case 'mousedown':
touchStartTimestamp = MouseEventShim.getEventTimestamp(evt); touchStartTimestamp = MouseEventShim.getEventTimestamp(evt);
evt.stopPropagation(); evt.stopPropagation();
startEvent = evt; startEvent = evt;
deltaX = 0;
attachEvents(); attachEvents();
break; break;


Expand All @@ -48,7 +49,7 @@ const GridManager = (function() {


// Start panning immediately but only disable // Start panning immediately but only disable
// the tap when we've moved far enough. // the tap when we've moved far enough.
var deltaX = evt.clientX - startEvent.clientX; deltaX = evt.clientX - startEvent.clientX;
if (deltaX == 0) if (deltaX == 0)
return; return;
document.body.dataset.transitioning = 'true'; document.body.dataset.transitioning = 'true';
Expand Down Expand Up @@ -170,6 +171,11 @@ const GridManager = (function() {
break; break;


case 'contextmenu': case 'contextmenu':
if (deltaX !== 0) {
evt.stopImmediatePropagation();
return;
}

if (currentPage > 1 && 'isIcon' in evt.target.dataset) { if (currentPage > 1 && 'isIcon' in evt.target.dataset) {
evt.stopImmediatePropagation(); evt.stopImmediatePropagation();
Homescreen.setMode('edit'); Homescreen.setMode('edit');
Expand Down

0 comments on commit 6eaab8f

Please sign in to comment.