Jump to content
Search Community

Unbinding/ releasing jQuery knob to allow binding to another target object.

bhakti test
Moderator Tag

Go to solution Solved by Diaco,

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 have a canvas with a number of draggable objects. The codepen represents just two. In the draggable callback, I send off the target eg red box, to a function which instantiates jQuery knob. The knob does its job and adjusts the size.

 

When I click on another object, say the blue box, I expect draggable to associate knob with now the blue box as target. Alas, it does not.

 

Can somebody tell me how to do this?

 

I also need to get the natural height of images in the draggabe callback so that I can calculate an x:y ration for proportional resizing....? I think I have seen someone instantiate a new image object from the src attr, and then get widht and height...?

 

Thanks

 

 

See the Pen wKzKNb?editors=101 by anon (@anon) on CodePen

Link to comment
Share on other sites

Hi bhakti  :)

 

this isn't related to GSAP , as you can see every thing works correctly , pls add console.log(target)  at the top of your doAnim() .

 

pls check this out : 

See the Pen ojzzjy by MAW (@MAW) on CodePen

 

Adding c.log to my pen certainly shows the different targets being fed into the repeatedly called doAnim(). In your pen c.log only ever reports one such object fed into doAnim() and at runtime. Got the naturalHeight when I stuck a real image there. Thanks.

 

From your pen I guess you are implying it's a topic closer to js functions, and variable scope. I'm amazed to see a function accept, and moreover employ, a change to a function parameter - after its been called. Maybe it remains 'open' cos it does not return anything?

 

Sorry about the 'off-topic' nature, though I do find there is a niche for common programming design solutions for fundamental animation techniques. I usually find that as a newbie, sticking my nose in, such a forum exists already - somewhere  ;)

 

Thanks again.

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