Closed lookfirst closed 9 years ago
This has been on my to-do list. Thanks for taking the time to implement it.
:+1: I had no choice, I needed this! Can you get this up on bower asap too? I'd like to stop using my fork.
I'm also not happy with the way that the direction needs to be passed in. I wish we could use Hammer's constant definitions. Not really sure how to make that work cleanly though. =(
Should be good to go when pulling from ryanmullins.github.io/angular-hammer. These changes also bumped the bower version to 2.0.6 (I was considering a minor bump but decided to just use a patch).
Also, the way I have it written in there it should be using the Hammer constants, at least for the custom recognizers. I'll check this out further tomorrow. One day I'll build a test suite too.
If I write: hm-gesture-options='{"pan": {"direction": Hammer.DIRECTION_ALL}}'
that blows up the json parser.
SyntaxError: Unexpected token H
at Object.parse (native)
at Object.fromJson (http://localhost:3000/assets/angular/angular.js?body=1:1105:14)
at link (http://localhost:3000/assets/ryanmullins-angular-hammer/angular.hammer.js?body=1:72:39)
hammer.js is included before angular.js
Yeah that makes sense. Drop the Hammer. part. I have it set to Lodi ally or the different bits based on strings containing the names of the constants and a | separator. Look at the last private function in that file and you'll see what I'm doing. Let me know how it goes.
Ryan
Sent from my iPhone
On Oct 26, 2014, at 21:06, Jon Stevens notifications@github.com wrote:
If I write: hm-gesture-options='{"pan": {"direction": Hammer.DIRECTION_ALL}}' that blows up the json parser.
— Reply to this email directly or view it on GitHub.
hm-gesture-options='{"pan": {"direction": DIRECTION_ALL}}'
SyntaxError: Unexpected token D
at Object.parse (native)
at Object.fromJson (http://localhost:3000/assets/angular/angular.js?body=1:1105:14)
at link (http://localhost:3000/assets/ryanmullins-angular-hammer/angular.hammer.js?body=1:72:39)
hm-gesture-options='{"pan": {"direction": "DIRECTION_ALL"}}'
doesn't work either (which also makes sense)
Two changes:
1) the json property is directions not direction
2) that's parsing JSON and you're not passing DIRECTION_ALL in as a string so the angular parser is failing. I did the same thing when I was testing a while ago, irritated the hell out of me.
Try that and let me know.
Ryan
Sent from my iPhone
On Oct 26, 2014, at 21:13, Jon Stevens notifications@github.com wrote:
hm-gesture-options='{"pan": {"direction": DIRECTION_ALL}}'
SyntaxError: Unexpected token D at Object.parse (native) at Object.fromJson (http://localhost:3000/assets/angular/angular.js?body=1:1105:14) at link (http://localhost:3000/assets/ryanmullins-angular-hammer/angular.hammer.js?body=1:72:39) — Reply to this email directly or view it on GitHub.
You're wrong on both points. =)
From the hammer docs: http://hammerjs.github.io/getting-started/
hammertime.get('pan').set({ direction: Hammer.DIRECTION_ALL });
And you can see above that I also tried passing it in as a string and it doesn't do anything meaningful.
Changed my JSON definition to use the direction variable name instead of directions. Pushed to the site. Try again, you're still not escaping your JSON properly, but you'll figure it out. Should read:
hm-gesture-options='{"pan": {"direction": "DIRECTION_ALL"}}'
If it's still failing I don't have time to fix it tonight, I have to get on a plane in 7 hours. This could be related to the fact that the code I merged from you doesn't make use of my string parsing function... Maybe start there.
opened a new pr for this.
fixes issue #3 example of making DIRECTION_ALL work for pan: hm-gesture-options='{"pan": {"direction": 31}}'