angular-hammer icon indicating copy to clipboard operation
angular-hammer copied to clipboard

requireFailure not working with doubletap

Open mattmcdev opened this issue 10 years ago • 13 comments

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

mattmcdev avatar Jan 07 '15 13:01 mattmcdev

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

RyanMullins avatar Jan 07 '15 14:01 RyanMullins

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

RyanMullins avatar Jan 07 '15 14:01 RyanMullins

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

mattmcdev avatar Jan 07 '15 14:01 mattmcdev

Still not working using v2.1.10.

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

mattmcdev avatar Jan 15 '15 11:01 mattmcdev

Looking into this now.

RyanMullins avatar Jan 15 '15 13:01 RyanMullins

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

RyanMullins avatar Jan 15 '15 15:01 RyanMullins

@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.

RyanMullins avatar Jan 15 '15 15:01 RyanMullins

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

mattmcdev avatar Jan 15 '15 16:01 mattmcdev

Awesome, thanks for dropping that in there.

RyanMullins avatar Jan 15 '15 16:01 RyanMullins

Thanks for looking into this bug :)

mattmcdev avatar Jan 15 '15 16:01 mattmcdev

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.

RyanMullins avatar Jan 15 '15 18:01 RyanMullins

No change using those versions.

mattmcdev avatar Jan 15 '15 19:01 mattmcdev

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

blakgeek avatar Aug 13 '15 17:08 blakgeek