Jump to content
Search Community

Draggable.update function does not exist

Kenner Stross test
Moderator Tag

Recommended Posts

I'm getting an error when trying to call draggable.update(boolean, boolean) - it says there is no such function. I went to an existing gsap code pen and made a quick modification just to see if the function can be invoked. You'll see the error on the console; same message I'm getting in my app.

 

var d = Draggable.create("#child", {
    type: "scroll",
    edgeResistance: 0.5,
    inertia: true,
  trigger: ".box",
});
d.update(false, false);

See the Pen ExKjoyq by kennerstross (@kennerstross) on CodePen

Edited by Kenner Stross
(Corrected the CodePen to include the d.update change)
Link to comment
Share on other sites

That's because Draggable.create() returns an Array of Draggable instances, so you're trying to call .update() on an Array instead of a Draggable instance. 

 

The .create() method returns an Array because you might pass in selector text that matches multiple elements, like Draggable.create(".box") (when there are multiple elements with the class "box"). 

 

So if you know yours will return just one result, you can simply do: 

var d = Draggable.create("#child", {
    type: "scroll",
    edgeResistance: 0.5,
    inertia: true,
  trigger: ".box",
})[0];
d.update(false, false);

Does that clear things up? 

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