Jump to content
Search Community

Controlling the drag position of an element that's already controlled via another element's scroll position

AaronRF test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

Hello!

 

Looking at the CodePen example, you can see that the position of the #slidingElement div is controlled with a draggable div (#DragItem). This is working beautifully but I've just learnt that #slidingElement itself should also be draggable, meaning that the progress of both the #slidingElement and #DragItem position need to be tracked and tied together accordingly. I tried to implement similar functionality for the #slidingElement as I did with #DragItem  but the functionality falls apart and they conflict with each other.

 

I've stripped it back to a usable state for the time being but

 

I hope this makes sense, I'm not 100% sure how I can go about achieving this and was hoping someone could shed some light on where I can go from here.

 

Many thanks,

Aaron

See the Pen xxejJdd by AaronRF (@AaronRF) on CodePen

Link to comment
Share on other sites

  • Solution

Hi,

 

Well I couldn't resist to create a simple demo of this, super fun!:

See the Pen BaEMOrd by GreenSock (@GreenSock) on CodePen

 

The magic numbers you see there are because:

  • The width of the wrapper is 80% the screen width.
  • The wrapper for the box has a 10 px padding on the left/right
  • The box element has a fixed width of 75px

 

Hopefully this helps.

Happy Tweening!

Link to comment
Share on other sites

  • 2 weeks later...

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