Jump to content
Search Community

Draggable start drag autromatically

xxboonexx test
Moderator Tag

Go to solution Solved by OSUblake,

Recommended Posts

  • Solution

Hi, you're going to need some type of event to trigger it. And you will probably need to move it where ever the mouse is.

 

var myDrag = new Draggable("#dragger");

window.addEventListener("mousemove", startDrag);

function startDrag(e) {
	window.removeEventListener("mousemove", startDrag);
	
    gsap.set("#dragger", {
		x: e.clientX,
		y: e.clientY
	});
  
	myDrag.startDrag(e);
}

 

  • Like 2
Link to comment
Share on other sites

49 minutes ago, OSUblake said:

Hi, you're going to need some type of event to trigger it. And you will probably need to move it where ever the mouse is.

 


var myDrag = new Draggable("#dragger");

window.addEventListener("mousemove", startDrag);

function startDrag(e) {
	window.removeEventListener("mousemove", startDrag);
	
    gsap.set("#dragger", {
		x: e.clientX,
		y: e.clientY
	});
  
	myDrag.startDrag(e);
}

 

Perfect, thanks so much!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...