Skip to main content
Uvox1
Known Participant
January 28, 2021
Question

How to make a smooth drag text in Adobe Animate?

  • January 28, 2021
  • 1 reply
  • 219 views

Hi!

I was looking on the net and I did not find the code - smooth, because drag text is a little hard and not smoothly dragging. How to make a smooth drag text in Adobe Animate?

Please help. Thank you!

 

My code:

var root = this;
var text = root.text;

root.start = function()
{
createjs.Touch.enable(stage);
stage.mouseMoveOutside = true;
text.transitionDelay = 350;
text.transitionEase = createjs.Ease.quintOut;

text.on("mousedown", root.mouseDownHandler);
text.on("pressmove", root.pressMoveHandler, this, false, { min: -430, max: 40 });
};

root.mouseDownHandler = function(e)
{
e.currentTarget.offsetY = stage.mouseY / stage.scaleY - e.currentTarget.y;
};

root.pressMoveHandler = function(e, data)
{
e.currentTarget.y = root.clamp(stage.mouseY / stage.scaleY - e.currentTarget.offsetY, data.min, data.max);
createjs.Tween.get(text).to( text.transitionDelay, text.transitionEase);
};

root.clamp = function(value, min, max)
{
if (value < min)
return min;


if (value > max)
return max;
return value;
};
root.start();

 

This topic has been closed for replies.

1 reply

Community Expert
March 3, 2021