Share Posted September 5, 2015 I was going through documentation and tried Draggable library and found a possible bug? But seems impossible to stay undetected. I thought I should report it. So if element passed to Draggable doesn't exist it throws error and javascript stops working as well. Are we suppose to make sure element exists and then create Draggable object? See the Pen meyagj by Sahil89 (@Sahil89) on CodePen Link to post Share on other sites
Share Posted September 5, 2015 Generally, yes, it's a bad idea to create a Draggable on an element that doesn't exist. However, I did add some code in the upcoming release that should alleviate this scenario where you pass in selector text that has no results. You can try it out with the [uncompressed] beta version: https://s3-us-west-2.amazonaws.com/s.cdpn.io/16327/Draggable-latest-beta.js 3 Link to post Share on other sites
Author Share Posted September 6, 2015 Clicking on draggable element gives mouse position as zero. Or it depends on different libraries we use to detect click position? Like in this case it is jQuery. See the Pen EVaqqZ by Sahil89 (@Sahil89) on CodePen Link to post Share on other sites
Author Share Posted September 7, 2015 While using static hitTest method, is there way to detect which element is on top? For example, return true only if first element is on top else false? Link to post Share on other sites
Solution Share Posted September 7, 2015 As for your pageX/pageY thing, that looks like a problem with jQuery and is completely unrelated to GreenSock code. You can tap into our code like this: Draggable.create(".draggable", { onClick: function(e) { console.log("clicked at ", e.pageX, e.pageY); } }); As for determining which element is on top, you could compare the zIndex of the elements. That's not something Draggable does for you in hitTest(). 1 Link to post Share on other sites
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now