Jump to content


Draggable, Throw, and onThrowUpdateScope

Recommended Posts



Using Draggable with throwProps I keep checking on a 'thrown' objects coords using onThrowUpdate.


My problem is based on needing a reference to two scopes.


One scope being the object that's thrown (the throw scope) and the other is the scope that I set in onThrowUpdateScope.


If I set "onThrowUpdateScope: this" so as it references my object and all my prototyped methods then I can't seem to reference the object with the 'throw' scope.


I would be very grateful if someone can show me how this is done...


Many thanks in advance...

Link to comment
Share on other sites



I'm having a little trouble following your question, maybe the few neurons that still work in my brain are spinning in the wrong way  :mrgreen:. Maybe you could set up a simple codepen in order to get a better grasp of what the issue could be.




Finally keep in mind that inside the Draggable instance, this refers to the instance itself and this.target refers to the DOM element being dragged/thrown.

Link to comment
Share on other sites



Thank you for your reply.


I've put together a short example of what I mean in CodePen.


To see what I mean, drag and throw the object. One line of output is correctly referenced, the other is undefined.


See the Pen KkfIo by anon (@anon) on CodePen


Basically I want my ScreenController.prototype.onThrowUpdate function to be able to access both scopes, ie, the scope of the throwprops object and also the scope defined in onThrowUpdateScope.


Hopefully that's more clear.

Link to comment
Share on other sites



Many thanks for your reply.


Your suggested solution worked perfectly :-)

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.