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

Commit

Permalink
Merge pull request #23759 from crdlc/bug-1062527
Browse files Browse the repository at this point in the history
Bug 1062527 - [Homescreen] Unable to launch apps after changing the date to a previous one
  • Loading branch information
KevinGrandon committed Sep 9, 2014
2 parents 3fd4304 + 795ef2c commit 3a99e64
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
40 changes: 40 additions & 0 deletions apps/sharedtest/test/unit/elements/gaia_grid/grid_view_test.js
@@ -0,0 +1,40 @@
/* global GridView, GridLayout */

'use strict';

require('/shared/elements/gaia_grid/js/grid_layout.js');
require('/shared/elements/gaia_grid/js/grid_view.js');

suite('GridView', function() {

var container;

setup(function() {
container = document.createElement('div');
document.body.appendChild(container);
});

teardown(function() {
document.body.removeChild(container);
});

test(' reset last scroll time after touchend event', function() {
this.sinon.stub(window, 'GridLayout');

var subject = new GridView({
features: {},
element: container
});

assert.equal(subject.lastScrollTime, 0);

subject.lastScrollTime = 1000;

container.dispatchEvent(new CustomEvent('touchend'));

assert.equal(subject.lastScrollTime, 0);

GridLayout.restore();
});

});
8 changes: 6 additions & 2 deletions shared/elements/gaia_grid/js/grid_view.js
Expand Up @@ -4,6 +4,7 @@
/* global GridLayout */
/* global GridZoom */
/* global LazyLoader */
/* global performance */

(function(exports) {

Expand Down Expand Up @@ -164,7 +165,7 @@

// bug 1015000
onScroll: function() {
this.lastScrollTime = Date.now();
this.lastScrollTime = performance.now();
},

onTouchStart: function(e) {
Expand All @@ -177,7 +178,10 @@
// Gecko does that automatically but since we want to use touch events for
// more responsiveness, we also need to replicate that behavior.
onTouchEnd: function(e) {
if (Date.now() - this.lastScrollTime < PREVENT_TAP_TIMEOUT) {
var lastScrollTime = this.lastScrollTime;
this.lastScrollTime = 0;
var diff = performance.now() - lastScrollTime;
if (diff > 0 && diff < PREVENT_TAP_TIMEOUT) {
return;
}

Expand Down

0 comments on commit 3a99e64

Please sign in to comment.