Jump to content
GreenSock

Cyboide

Draggable and mouseover mouseout

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

Hi,

 

I’m having weird behavior with mouseover and mouseout events being triggered only sporadically on elements inside a Draggable.

 

I actually want them to fire, but It seems they don’t at all until I used the draggable a first time, and then it works, but then with more subsequent dragging sometimes it works, sometimes not.

 

Any idea?

Link to comment
Share on other sites

Hi,

 

Could you give us more details and a live sample?.

 

This setup is working for me:

See the Pen fLimI by rhernando (@rhernando) on CodePen

 

Feel free to fork it and accommodate it to your scenario in order to get a better look at the issue you're having.

 

Rodrigo.

  • Like 2
Link to comment
Share on other sites

True enough it works fine in your example. Must be something specific in what I’m working on.

 

Thanks for your quick reply.

  • Like 1
Link to comment
Share on other sites

I'm at day one of learning this stuff so go easy on me.  When I'm in the code pen environment Draggable works fine.  When I copy the code to dreamweaver I notice there's no link to the jquery  in the html so I add the link.  I get the Uncaught ReferenceError: jQuery is not defined

jquery.gsap.min.js:14

 

this is my code:

 <!DOCTYPE html><html>
<head>
<meta charset="utf-8" />
<title>Draggable</title>
<script src="bonus-all/HTML5/src/minified/jquery.gsap.min.js"></script>
<script src="bonus-all/HTML5/src/minified/TweenMax.min.js"></script>
<style>
body
{
  background:#000;
  font: 15px "Trebuchet MS", Arial, Helvetica, sans-serif;
  color: #fff
}


h2
{
  font:bold 16px;
  text-align:center;
}


#draggable-element
{
  position: relative;
  width: 600px;
  height:400px;
  margin:50px;
  background: #222;
  border: solid 1px #fff;
}


.child-element
{
  width: 75px;
  height:75px;
  position: relative;
  background: #00f;
  border: solid 1px #f0f;
}


#logDiv
{
  background:#444;
  padding:5px;
  border:solid 1px #fff;
  width:150px;
}
</style>
</head>
<body>
<h2>
  Mouse Over Event on Draggable instance's Children
</h2>


<div id="draggable-element">
  <div class="child-element" id="first-child">First Child</div>
  <div class="child-element" id="second-child">Second Child</div>
  <div class="child-element" id="third-child">Third Child</div>
</div>
<div id="logDiv">
</div>
<script>
var draggableParent = $("#draggable-element"),
    draggableChilds = $(".child-element"),
    logDiv = $("#logDiv");


Draggable.create(draggableParent,
{
  type:'x,y'
});


$.each(draggableChilds, function(i,e)
{
  var childId = $(e).attr('id');


  $(e).mouseover(function()
  {
    logDiv.html(childId);
  });
});
</script>
</body>
</html>
Link to comment
Share on other sites

jquery.gsap.min.js is not jQuery. It's the GSAP plugin for jQuery. You'll need to include jQuery as well.

  • Like 3
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.
×