fix(tap): Deactivate elements during scroll at the same time click is ignored, #997

Previously I disabled the activation class immediately on a touchmove,
where as the click will still work if you touchstart and touchend
within a few pixels of each other. So visually it may have looked like
the click shouldn't have worked. I just updated it so the use the same
numbers. For example, if you hold down an item and move just 5 pixels,
the item will stay active (before it wouldn't have), and the click will
fire. But at the same time, if you hold down an item, and move a larger
distance, once it realizes that it went farther than 6 pixels it'll not
allow a click to happen, AND it'll not show the item as being active.
This commit is contained in:
Adam Bradley
2014-04-03 23:24:31 -05:00
parent 4ff6acb10e
commit 3ee5ea77a6
4 changed files with 29 additions and 9 deletions

View File

@@ -267,11 +267,14 @@
});
var mouseTimerId;
var mouseMoveCount = 0;
function onMouseMove(e) {
clearTimeout(mouseTimerId);
mouseTimerId = setTimeout(function(){
var el = document.getElementById('mousemove-notify');
el.style.display = 'block';
mouseMoveCount++;
el.innerText = 'Mouse Move! ' + mouseMoveCount;
clearTimeout(mouseTimerId);
mouseTimerId = setTimeout(function(){
el.style.display = 'none';
@@ -280,11 +283,14 @@
}
var touchTimerId;
var touchMoveCount = 0;
function onTouchMove(e) {
clearTimeout(touchTimerId);
touchTimerId = setTimeout(function(){
var el = document.getElementById('touchmove-notify');
el.style.display = 'block';
touchMoveCount++;
el.innerText = 'Touch Move! ' + touchMoveCount;
clearTimeout(touchTimerId);
touchTimerId = setTimeout(function(){
el.style.display = 'none';

View File

@@ -71,16 +71,16 @@ describe('Ionic Tap', function() {
it('Should setStart and hasScrolled true if >= touch tolerance', function() {
ionic.tap.setStart({ clientX: 100, clientY: 100 });
var s = ionic.tap.hasScrolled({ clientX: 105, clientY: 100 });
var s = ionic.tap.hasScrolled({ clientX: 111, clientY: 100 });
expect(s).toEqual(true);
s = ionic.tap.hasScrolled({ clientX: 95, clientY: 100 });
s = ionic.tap.hasScrolled({ clientX: 89, clientY: 100 });
expect(s).toEqual(true);
s = ionic.tap.hasScrolled({ clientX: 100, clientY: 103 });
s = ionic.tap.hasScrolled({ clientX: 100, clientY: 107 });
expect(s).toEqual(true);
s = ionic.tap.hasScrolled({ clientX: 100, clientY: 97 });
s = ionic.tap.hasScrolled({ clientX: 100, clientY: 93 });
expect(s).toEqual(true);
s = ionic.tap.hasScrolled({ clientX: 100, clientY: 200 });