RyanMullins / angular-hammer

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

Does it make sense to make use of requestAnimationFrame? #6

Closed 27leaves closed 9 years ago

27leaves commented 9 years ago

I wonder if you could increase performance by using requestAnimationFrame. For example on a pan event you could $apply your scope in a requestAnimationFrame. Do you have any experience on this topic and do you know why this would/wouldn't work?

RyanMullins commented 9 years ago

Sorry, but I do not have experience using requestAnimationFrame.

RyanMullins commented 9 years ago

@creat-or can you elaborate on this a bit, especially in the context of the current code base. I am considering it for inclusion in v2.2.0 but am unfamiliar with the topic and could use a primer. Please respond on or before 31 Jan 2015, otherwise I will close this issue.

27leaves commented 9 years ago

My problem was that I ran into performance issues, because $apply gets called on every touchmove event (and that is/can be very expensive). As I can remember I had the best performance when I removed angular completely out of the pan-behaviour and manually attached Hammer events. In those events I manually moved CSS attributes (transform: translate3d) instead of setting scope variables.

I also tried to use requestAnimationFrame, but had no improvement (just perceived). So imho you can close the issue.

RyanMullins commented 9 years ago

Thanks for commenting and exploring this issue. If you find a solution in the future please let me know and I will include it in a future release.