Skip to main content
rogersub
Participating Frequently
January 29, 2018
Answered

Pinch, Swipe and Drag functions using hammer.js in Animate CC

  • January 29, 2018
  • 1 reply
  • 3575 views

Hi, I have an html5 canvas movie that I would like to be able to recognize Pinch, Swipe and Drag gestures when using touch screens such as smartphones or tablets.

I am linking my html to the hammer.js library:

<script src="https://hammerjs.github.io/dist/hammer.js"></script>

However, I don’t know which functions I have to call in Animate CC canvas to Pinch, Swipe and Drag my movie symbol.

Can anyone help with the code needed to make this functions work?

Many thanks in advance!

This topic has been closed for replies.
Correct answer ClayUUID

Animate declares a global variable "canvas" which points to its canvas element. So just plug in "canvas" where the example code has "hammertime".

1 reply

Legend
January 29, 2018

I'm not familiar with Hammer, but if it was written to work with the browser DOM (almost certainly), then it won't work with Animate Canvas objects, because Canvas objects are not DOM objects. All Hammer will see is the single canvas element that Animate uses to render the stage.

rogersub
rogersubAuthor
Participating Frequently
January 29, 2018

OK, thanks for your reply. I understand.
Anyways, if anyone knows how to call the Pinch, Swipe and Drag functions for the whole canvas element?

ClayUUIDCorrect answer
Legend
January 29, 2018

Animate declares a global variable "canvas" which points to its canvas element. So just plug in "canvas" where the example code has "hammertime".