Skip to content

Configs

Here is a list of all the configurations.

General

Example

vue
<script setup>
import { ref } from 'vue'
const options = ref({
    startScroll: () => {
        console.log("start scroll");
    },
    endScroll: () => {
        console.log("end scroll");
    },
    speed: 1, // default is 1
    reverseDirection: false, // default is false
    hideScrollbar: false, // default is false
});
</script>

<template>
    <div v-drag-scroller="options">
    </div>
</template>
NameDescriptionTypeDefault
startScrollTrigger when start scrollFunctionnull
endScrollTrigger when end scrollFunctionnull
speedSpeed of scrollNumber1
hideScrollbarHide scrollbarBooleanfalse
reverseDirectionReverse direction of scrollBooleanfalse

Binding value:

you can pass binding value to directive like this:

vue
<template>
    <div v-drag-scroller.onlyX>
    </div>
</template>
vue
<template>
    <div v-drag-scroller.disablechild>
    </div>
</template>
NameDescriptionTypeDefault
disablechildDisable drag scroll in all childBooleanfalse
onlyXOnly scroll in X axisBooleanfalse
onlyYOnly scroll in Y axisBooleanfalse

Priority: disablechild > drag-scroller-disable > onlyX > onlyY

Events (use in options):

NameDescription
startScrollTrigger when start scroll
endScrollTrigger when end scroll
onScrollingTrigger when drag and move mouse

Example

vue
<script setup>
const onScroll = (e) => {
  console.log("working",e);
};

const onEndScroll = (e) => {
  console.log("end scroll",e);
};

const options = {
    startScroll: onScroll,
    endScroll: onEndScroll,
};

</script>

// in component 
<template>
    <div v-drag-scroller="options">
    </div>
</template>

Released under the MIT License.