Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Drag and drop smoothly Animate CC Canvas

Community Beginner ,
Nov 17, 2017 Nov 17, 2017

I am using Animate CC, Canvas, I'm trying to drag my background scene along the X axis, the code I have so far is

this.scene.addEventListener("pressmove", dragMe.bind(this));  function dragMe (evt) { this.addChild(evt.currentTarget); var p = this.globalToLocal(evt.stageX, evt.stageY); evt.currentTarget.x = p.x; }

However each time I drag the background it snaps the image to the mouse (depending on where the axis - rotation point - is placed in Animate CC). This makes for an unsmooth drag, I would like something more like a touch screen interaction where I can just keep dragging/swiping it along.

I can't seem to find a solution anywhere for this.

Thanks in advance.

2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 17, 2017 Nov 17, 2017

Yes - by default, the x and y are calculated from teh registration point.

Have a look at the following example as it seems to accomplish what you are looking to do:

Draggable Canvas - JSFiddle

Translate
Community Expert ,
Nov 17, 2017 Nov 17, 2017

Yes - by default, the x and y are calculated from teh registration point.

Have a look at the following example as it seems to accomplish what you are looking to do:

Draggable Canvas - JSFiddle

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 20, 2017 Nov 20, 2017

Wow! Yes!!! This is exactly what I was looking for, that's perfect thanks! I knew there had to be a way.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 20, 2017 Nov 20, 2017

Hi,

Please excuse my ignorance, I really am just starting to learn all this.

Within Animate CC I can't seem to find a way to give the canvas an id, so the code can't reference anything and therefore the drag doesn't work (or at least I assume that's the issue).

Have you any idea how to make this work in Animate CC or am I just making my life complicated?

Thanks again

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 20, 2017 Nov 20, 2017
LATEST

The canvas is given the ID "canvas".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines