Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/huynamboz/vue-drag-scroller

This vue npm package help you drag to scroll easier🌟
https://github.com/huynamboz/vue-drag-scroller

drag dragscroll npm-package vue vue2 vue3

Last synced: 3 days ago
JSON representation

This vue npm package help you drag to scroll easier🌟

Awesome Lists containing this project

README

        

# Vue drag scroller ⚡️

![image](https://github.com/huynamboz/vue-drag-scroller/assets/38585889/57cc7cf2-1273-4416-8fcb-df8262a4af49)

[![npm version](https://img.shields.io/npm/v/vue-drag-scroller.svg)](https://www.npmjs.com/package/vue-drag-scroller)
[![npm download](https://img.shields.io/npm/dm/vue-drag-scroller.svg)](https://www.npmjs.com/package/vue-drag-scroller)
[![npm license](https://img.shields.io/npm/l/vue-drag-scroller.svg)](https://www.npmjs.com/package/vue-drag-scroller)

This package help you drag to scroll easier🌟

[Docs and demo](https://huynamboz.github.io/vue-drag-scroller/)

https://github.com/huynamboz/vue-drag-scroller/assets/38585889/20139bab-0004-4249-8826-70959f6dbc77

## How to install🔖
**NPM**

npm install vue-drag-scroller
**YARN**

yarn add vue-drag-scroller

## Install🔖

Use with vue 3:

**Register global:**
```javascript
//main.ts
import { createApp } from 'vue'
import VueDragScroller from "vue-drag-scroller"

import App from './App.vue'

const app = createApp(App)
app.use(VueDragScroller)
app.mount('#app')
```

``` html
//Example.vue


```
**Register local:**
```javascript
// Example.vue

import { dragScroller as vDragScroller } from "vue-drag-scroller"


```
**Register in Nuxt:**
```javascript
// plugins/vue-drag-scroller.js
import VueDragScroller from 'vue-drag-scroller'

export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(VueDragScroller)
})
```
```javascript
// nuxt.config.js
export default defineNuxtConfig({
plugins: ['~/plugins/vue-drag-scroller.ts'],
})
```

## Config🔖
### Options:
you can pass options to directive like this:
```javascript

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
});


```
| Name | Description | Type | Default |
|--|--|--|--|
| startScroll | Trigger when start scroll | Function | null |
| endScroll | Trigger when end scroll | Function | null |
| speed | Speed of scroll | Number | 1 |
| hideScrollbar | Hide scrollbar | Boolean | false |
| reverseDirection | Reverse direction of scroll | Boolean | false |
### Binding value:
you can pass binding value to directive like this:
```javascript


```

```javascript


```

| Name | Description | Type | Default |
|--|--|--|--|
| disablechild | Disable drag scroll in all child | Boolean | false |
| onlyX | Only scroll in X axis | Boolean | false |
| onlyY | Only scroll in Y axis | Boolean | false |

Priority: disablechild > drag-scroller-disable > onlyX > onlyY
### Events (use in options):
| Name | Description |
|--|--|
| startScroll | Trigger when start scroll|
| endScroll | Trigger when end scroll|
| onScrolling | Trigger when drag and move mouse|
#### Example
```javascript

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

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

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

// in component


```
- ### Events Listener with v-on or @
#### Example with @
```javascript


```
#### Example with v-on
```javascript


```
- ### Drag parent except all child
#### Example
```javascript






```
- ### Drag parent except particular child
#### Example
```javascript


// disable drag scroll



```
- ### Only scroll in X axis
#### Example
```javascript


```
- ### Only scroll in Y axis
#### Example
```javascript


```
- ### Hide scrollbar
#### Example
```javascript


```
- ### Change speed of scroll
#### Example
```javascript


```
- ### Change direction of scroll
#### Example
```javascript


```