RyanMullins / angular-hammer

Hammer.js v2 support for AngularJS
http://ryanmullins.github.io/angular-hammer/
MIT License
188 stars 55 forks source link

requireFailure not working with doubletap #23

Open mattmcdonald-uk opened 9 years ago

mattmcdonald-uk commented 9 years ago

When you add requireFailure of doubletap you get a TypeError: "TypeError: Cannot read property 'requireFailure' of null at db.V.requireFailure".

Changing the requireFailure to swipe, pan, etc. all works.

<div id="trigger"
    hm-tap="onHammer"
    hm-doubletap="onHammer"
    hm-recognizer-options='[
        {"type":"singletap", "requireFailure":"doubletap"}
    ]' ></div>

Simillarly, using a recognizeWith of singletap also doesn't work.

This example from hammerjs shows the regular usage of these options: http://codepen.io/jtangelder/pen/pBuIw

RyanMullins commented 9 years ago

I'll take a look later this week. In a bit of a time crunch for some work-related stuff.

RyanMullins commented 9 years ago

Looking at that, there's a chance that the "requireFailure":"doubletap" is actually being applied to the double tap recognizer.

mattmcdonald-uk commented 9 years ago

I get the same problem if I remove hm-doubletap from the element.

mattmcdonald-uk commented 9 years ago

Still not working using v2.1.10.

Slightly different error: "TypeError: Cannot read property 'requireFailure' of null at TapRecognizer.Recognizer.requireFailure "

RyanMullins commented 9 years ago

Looking into this now.

RyanMullins commented 9 years ago

If you want to track my work, I'm debugging this here: http://plnkr.co/edit/KwuQrxV2cFhnwRnBfZj3

RyanMullins commented 9 years ago

@mattmcdonald-uk Can you give me a more detailed error log? I'm having trouble reproducing this and I would like to see what line it's on/referencing.

mattmcdonald-uk commented 9 years ago

Seeing the exact same issue in your plunker.

Error output from Chrome below:

TypeError: Cannot read property 'requireFailure' of null
at TapRecognizer.Recognizer.requireFailure (http://ryanmullins.github.io/angular-hammer/bower_components/hammerjs/hammer.js:1263:28)
at setupRecognizerWithOptions (http://ryanmullins.github.io/angular-hammer/angular.hammer.js:403:18)
at http://ryanmullins.github.io/angular-hammer/angular.hammer.js:199:19
at Object.forEach (http://ryanmullins.github.io/angular-hammer/bower_components/angular/angular.js:325:18)
at link (http://ryanmullins.github.io/angular-hammer/angular.hammer.js:184:23)
at nodeLinkFn (http://ryanmullins.github.io/angular-hammer/bower_components/angular/angular.js:6711:13)
at compositeLinkFn (http://ryanmullins.github.io/angular-hammer/bower_components/angular/angular.js:6105:13)
at nodeLinkFn (http://ryanmullins.github.io/angular-hammer/bower_components/angular/angular.js:6705:24)
at compositeLinkFn (http://ryanmullins.github.io/angular-hammer/bower_components/angular/angular.js:6105:13)
at compositeLinkFn (http://ryanmullins.github.io/angular-hammer/bower_components/angular/angular.js:6108:13) <div id="trigger" class="target" hm-tap="onHammer" hm-doubletap="onHammer" hm-recognizer-options="[{&quot;type&quot;:&quot;tap&quot;, &quot;requireFailure&quot;:&quot;doubletap&quot;}]" style="touch-action: manipulation; -webkit-user-select: none; -webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);">angular.js:10071 (anonymous function)angular.js:7364 (anonymous function)angular.js:6714 nodeLinkFnangular.js:6105 compositeLinkFnangular.js:6705 nodeLinkFnangular.js:6105 compositeLinkFnangular.js:6108 compositeLinkFnangular.js:6001 publicLinkFnangular.js:1449 (anonymous function)angular.js:12701 Scope.$evalangular.js:12799 Scope.$applyangular.js:1447 (anonymous function)angular.js:3966 invokeangular.js:1445 doBootstrapangular.js:1459 bootstrapangular.js:1368 angularInitangular.js:22019 (anonymous function)jquery.min.js:2 jjquery.min.js:2 k.fireWithjquery.min.js:2 m.extend.readyjquery.min.js:2 J
RyanMullins commented 9 years ago

Awesome, thanks for dropping that in there.

mattmcdonald-uk commented 9 years ago

Thanks for looking into this bug :)

RyanMullins commented 9 years ago

Hmm... That version of Hammer is old. I've updated it to v2.0.4. Some locations moved too, so use these links:

http://ryanmullins.github.io/angular-hammer/examples/raw/hammer.js http://ryanmullins.github.io/angular-hammer/examples/raw/angular.js

Take a look at it now and see what happens. I think you might still get a similar error, but I just want to be sure we're on the latest and greatest.

mattmcdonald-uk commented 9 years ago

No change using those versions.

blakgeek commented 8 years ago

I fixed this by adding another additional directive named hm-require-failure that runs after all the recognizers are created. The problem is that hammer needs both of the recognizers to exist when enabling require failure. The current implementation tries to apply the recognizers options as it processes each recognizer directive.

You can see the details here in the PR https://github.com/RyanMullins/angular-hammer/pull/57