Jump to content
Search Community

Over / Out events on Draggable

weatherbrow test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hello weatherbrow, and Welcome to the GreenSock Forum!

 

I don't see anything in the GSAP Docs for detecting hover events. There are methods for hitTest(), to detect when two elements collide with each others space.

 

But you could just try and create hover event handlers for the element or element(s) you are hovering over.

 

Using jQuery on() method to bind events for hover, mouseenter and mouseleave

 

Example:

See the Pen ZYOjKK by jonathan (@jonathan) on CodePen


 

// set initial drag position
TweenLite.set("#dragme",{x:30,y:30});

// Create Draggable instance
Draggable.create("#dragme", {type:"x,y",
	bounds:"#container",
	edgeResistance:0.5,
	throwProps:true
});

// using jquery on() method to bind hover events for cross browser
$(document).on("mouseenter", "#dragme", function(){
  
     console.log("mouse enter element");
  
}).on("mouseleave", "#dragme", function(){
  
     console.log("mouse leave element");
  
});

:

I hope this helps! :)

  • Like 2
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...