Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1032106 - [Vertical Homescreen] Pressing the home button returns …
Browse files Browse the repository at this point in the history
…to top after showing context menu
  • Loading branch information
crdlc authored and KevinGrandon committed Jul 1, 2014
1 parent 23ab5a0 commit f7bd74e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
7 changes: 6 additions & 1 deletion apps/verticalhome/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
window.addEventListener('gaiagrid-dragdrop-begin', this);
window.addEventListener('gaiagrid-dragdrop-finish', this);

window.addEventListener('context-menu-open', this);
window.addEventListener('context-menu-close', this);

// some terrible glue to keep track of which icons failed to download
// and should be retried when/if we come online again.
this._iconsToRetry = [];
Expand Down Expand Up @@ -154,11 +157,13 @@
break;

case 'gaiagrid-dragdrop-begin':
// Home button disabled while dragging
case 'context-menu-open':
// Home button disabled while dragging or the contexmenu is displayed
window.removeEventListener('hashchange', this);
break;

case 'gaiagrid-dragdrop-finish':
case 'context-menu-close':
window.addEventListener('hashchange', this);
break;

Expand Down
17 changes: 15 additions & 2 deletions apps/verticalhome/test/unit/app_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ suite('app.js > ', function() {

mocksHelperForApp.attachTestHelpers();

var raf;

function initialize() {
app.scrollable.style.height = '500px';
app.scrollable.style.overflow = 'auto';
Expand All @@ -28,20 +30,31 @@ suite('app.js > ', function() {
}

setup(function(done) {
raf = sinon.stub(window, 'requestAnimationFrame');
loadBodyHTML('/index.html');
require('/js/app.js', function() {
initialize();
done();
});
});

teardown(function() {
raf.restore();
});

test('Scrolls on hashchange', function() {
var previousScrollTop = app.scrollable.scrollTop = 100;
var raf = sinon.stub(window, 'requestAnimationFrame');
window.dispatchEvent(new CustomEvent('hashchange'));

assert.isTrue(previousScrollTop > app.scrollable.scrollTop);
assert.ok(raf.called);
assert.isTrue(raf.called);
});

test('No scrolling while context menu is displayed', function() {
window.dispatchEvent(new CustomEvent('context-menu-open'));
window.dispatchEvent(new CustomEvent('hashchange'));
assert.isFalse(raf.called);
window.dispatchEvent(new CustomEvent('context-menu-close'));
});

});

0 comments on commit f7bd74e

Please sign in to comment.