donmbelembe / vue-dragscroll

A vue directive to make a scrollable element scroll by draging to the scroll direction
https://vue-dragscroll.clebinfosys.com/
MIT License
261 stars 32 forks source link

Propose to manage drag on child elements #29

Closed Aterbonus closed 5 years ago

Aterbonus commented 5 years ago

Currently the directive doesn't have a granular way to select which childrens can be dragged or not. To solve this issue I propose that the directive supports data attributes that indicates if a child element can be dragged or not.

Examples:

<div v-dragscroll>
    <div data-no-dragscroll></div><!-- can't be dragged -->
    <div></div><!-- can be dragged -->
</div>

<div v-dragscroll:nochilddrag>
    <div></div><!-- can't be dragged -->
    <div data-dragscroll></div><!-- can be dragged -->
</div>

With this the firstchilddrag arg is not necessary. firstchilddrag only supports one child, the first, and at the moment can cause unexpected behavior if the html is not minimized (element.firstChild can give you a text node and if the html is not minimized firstChild can be a text node of spaces).

This can support issue #23 and other use cases.

If the support for firstchilddrag is dropped this is a breaking change, so I open this issue for dicussion before opening a PR.

Thanks for this plugin :)

Aterbonus commented 5 years ago

PR sended. This adds the ability to select which childs can or can't be dragged. I didn't drop support for firstchilddrag, so this feature is not a breaking change, but I wrote in the docs that the data attributes are the way to go.

Writing this I thought that we may need a way to tell which elements together with the elements inside them can be dragged or not. But that will be another PR ;)

donmbelembe commented 5 years ago

Thanks 3c6a793