Permalink
Browse files

register only once mouse/touch event.

  • Loading branch information...
1 parent 6b739ab commit 0d3b51d3726cc1ade46f2942ae70553ed32564ac @ngryman committed Mar 2, 2013
Showing with 16 additions and 12 deletions.
  1. +8 −3 src/jquery.finger.js
  2. +8 −9 test/jquery.finger_test.js
View
@@ -90,8 +90,10 @@
var fingerCustom = {
setup: function() {
- $.event.add(this, startEvent + '.finger', startHandler);
- $.data(this, 'finger', {});
+ if (!$.data(this, 'finger')) {
+ $.event.add(this, startEvent + '.finger', startHandler);
+ $.data(this, 'finger', {});
+ }
},
add: function(handleObj) {
@@ -103,7 +105,10 @@
},
teardown: function() {
- $.event.remove(this, startEvent + '.finger', startHandler);
+ if ($.data(this, 'finger')) {
+ $.event.remove(this, startEvent + '.finger', startHandler);
+ $.data(this, 'finger', null);
+ }
}
};
@@ -102,7 +102,6 @@
describe('jquery.finger', function() {
beforeEach(function() {
this.$elems = $('#qunit-fixture .touchme');
- console.log('=============');
});
afterEach(function() {
@@ -211,14 +210,14 @@
});
});
-// it('should not trigger press when tapping twice', function(done) {
-// var handler = sinon.spy();
-// $('body').on('press', '.touchme', handler);
-// this.doubleTap(function() {
-// handler.should.not.have.been.calledOnce;
-// done();
-// }, $.Finger.pressDuration);
-// });
+ it('should not trigger press when tapping twice', function(done) {
+ var handler = sinon.spy();
+ $('body').on('press', '.touchme', handler);
+ this.doubleTap(function() {
+ handler.should.not.have.been.calledOnce;
+ done();
+ }, $.Finger.pressDuration);
+ });
});
describe('double tap event', function() {

0 comments on commit 0d3b51d

Please sign in to comment.