anseki / plain-draggable

The simple and high performance library to allow HTML/SVG element to be dragged.
https://anseki.github.io/plain-draggable/
MIT License
773 stars 99 forks source link

Use drag item in combinaison with Flickity handle #42

Closed yepecece closed 4 years ago

yepecece commented 4 years ago

Hi, I am trying to use a drag item with Flickity (https://flickity.metafizzy.co). Do you have an idea as how I could bind the drag of the item with the drag of the slider?

Basically I want the custom handle in Flickity to be the draggable element setup with PlainDraggable. If you see in the JSFiddle bellow, the gray square is the custom handle that is used to switch slides in Flickty on drag.

Here is a basic slider with a custom handle and the draggable item. https://jsfiddle.net/1unbwmja/10/

Thanks

anseki commented 4 years ago

Hi @yepecece, thank you for the comment.

You can get the handle element and pass it to PlainDraggable.

new PlainDraggable(document.querySelector('.custom-handle'))

However, that element is already able to be draggable by Flickity, you don't have to use PlainDraggable. Sorry, I couldn't understand what you want to do and why you use PlainDraggable well.

yepecece commented 4 years ago

You are right, I guess I was first trying to achieve the handle separately from Flickity which is why I used PlainDraggable.

Here is the JSFiddle in case someone is interested. https://jsfiddle.net/z2punLra/1/

Thanks for your help.

anseki commented 4 years ago

I see. If you want to add a handle, you can do that easily because you can control the Flickity by using its APIs. For example: https://jsfiddle.net/7kyznh43/ This is a case that uses jQuery, of course you can do that without jQuery, it's more better.

yepecece commented 4 years ago

Thanks. Great libraries by the way.

anseki commented 4 years ago

:smile: