Jump to content
Search Community

Draggable Content

Sukru test
Moderator Tag

Go to solution Solved by ryan_labar,

Recommended Posts

Hello, I made draggable content, but there is a problem in my code to move it by dragging left and right, but I could not solve it. Can you help with the Codepen link?

 

//Draggable Start
let tickerElement = document.querySelector(".ticker");

Draggable.create(tickerElement, {
  type: "x",
  edgeResistance: 1,
  bounds: ".ticker-slider",
  onDrag: updateTickerPosition
});

function updateTickerPosition() {
  let newPosition = tickerElement.getBoundingClientRect().left;
  gsap.set(".ticker-content", { x: newPosition });
}
//Draggable End

 

See the Pen abXQxWJ by sukruemanet (@sukruemanet) on CodePen

Link to comment
Share on other sites

  • Solution

I'm thinking that because you're using draggable to modify an animation, you'll want to setup a proxy element to use as your draggable item to update the slider's position. Similar to what's happening here:

See the Pen GRxNJGK?editors=0010 by elegantseagulls (@elegantseagulls) on CodePen

and

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

and

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

  • Like 2
Link to comment
Share on other sites

Just to be clear, this solution was already provided in the other thread: 

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

 

But @Sukru doesn't seem to want to use that and hasn't provided a minimal demo that shows why (claims there are issues). As far as I can tell, it delivers all the requested functionality. He has been informed that it's not a trivial task to wire up all the seamless looping with Draggable functionality in the ticker helper function he's using, and it's well beyond the scope of help we can provide for free in these forums.

 

@Sukru I'm still unsure why you're so reluctant to use the solution provided or what problems you think there are with it, but you are welcome to post a minimal demo that clearly shows why and we'd be happy to take a look. Just make sure you set up your HTML/CSS such that there aren't any transforms necessary in the native state. It's typically much easier to do that anyway rather than relying on transforms to lay everything out. 

 

Good luck!

Link to comment
Share on other sites

Sorry, @Sukru, I've been very clear over and over and over again - what you're asking us to do for you is way beyond the scope of help we can provide for free in these forums. It is not as simple as just switching a target on your Draggable. 

 

As stated in the other (duplicate) thread, your options are: 

  1. Use the solution I already provided that offers all the features (draggable, inertia, gradually pausing/resuming on hover, infinite repeating, snapping, etc.) 
  2. Use the "ticker" one you're already attempting, but wire up the Draggable functionality yourself. You are welcome to look at the demo I provided and try to borrow the Draggable logic for that, but I don't think that'll be simple for you. 
  3. Hire someone to help you. We do offer paid consulting services but there's a 4-hour minimum so you'd have to judge if the expense is worth it. 

Good luck!

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