Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
joris-rotteveel

Draggable Proxy and clickable children

Recommended Posts

Hi guys,

 

looking at the docs (https://greensock.com/docs/v3/Plugins/Draggable), setting either

dragClickables:true

or adding the data attribute on the HTML element you want to be clickable

data-clickable="true"

would make the browsers default behaviour take precedence. However, using the proxy approach, the draggable is only an empty div.

Are there best practises on making children clickable in this case? 

 

One solution that came to mind was to find the closest element based on it's x/y position and the click x/y , but hopefully there is a smarter way of doing this?

 

See the Pen jOPMdKL by joris-rotteveel (@joris-rotteveel) on CodePen

Share this post


Link to post
Share on other sites

Hey Joris and welcome.

 

You've got a couple of JS error in the bottom part of your JS. 

 

I'm curious - why use a proxy at all in this case? Here's how I'd do it.

See the Pen QWbKYPO?editors=0010 by GreenSock (@GreenSock) on CodePen

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks for spotting that error, updated the pen.

 

I will abandon the Proxy approach, it is clearly not  the right approach when dealing with regular DOM elements 🤦‍♂️. It will come in handy  when dealing  canvas/webgl and Draggable.

 

Thanks for the reply!

  • Like 1

Share this post


Link to post
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.

×