Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
LeoZ

Select div box on click and place into another box on click

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

Hello GreenSock community,

 

I'm trying to implement one functionality opposite to drag and drop. 

I want to select div on single click and place it on click on any empty place boxes. So both things should be done by using single mouse click.

Can anyone guide how can I achieve this using GreenSock. Thanks in advance.

 

See the Pen qLvQbO by LeoZoe (@LeoZoe) on CodePen

Link to post
Share on other sites

Hi @LeoZ,

 

If the objects are next to or above each other, it can work that way.
If a random placement is required, a bit of math and some conditions are needed ...

 

See the Pen qLvLrp by mikeK (@mikeK) on CodePen

 

Happy tweening ...

Mikel

 

 

  • Like 2
Link to post
Share on other sites

Thanks Mike,

 

Actually, it is started to moving on click but I want to select it on click and when I click on any empty box, then it will be moved into that box. Also, placement is random so I will try applying some math now.

 

Also it would be great if you help me with that too.

 

Link to post
Share on other sites

Hi @LeoZ,

 

 

I have no idea if something like this works with a double click (1st click: button selection, 2nd click: free field selection ??).

 

Here a random version

 

 

See the Pen LMawRe by mikeK (@mikeK) on CodePen

 

Kind regards

Mikel

 

 

  • Like 2
Link to post
Share on other sites

Hi @LeoZ

 

And here is a variant for two clicks.
However, very sensitive; the staggered buttons and the occupied places would still have to be blocked.

 

See the Pen VqNpwr by mikeK (@mikeK) on CodePen

 

Happy clicking ...

Mikel

 

 

Link to post
Share on other sites

Hi,

 

It did not let me go ...

 

See the Pen PXveRy by mikeK (@mikeK) on CodePen

 

Now its more or less safe.

 

Mikel

 

 

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

×