npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-drag-scroller

v1.8.6

Published

A vue directive that helps you scroll in a more natural way.

Downloads

554

Readme

Vue drag scroller ⚡️

image

npm version npm download npm license

This package help you drag to scroll easier🌟

Docs and demo

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:

//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')
//Example.vue
<template>
	<div v-drag-scroller>
	</div>
</template>

Register local:

// Example.vue
<script>
    import { dragScroller as vDragScroller } from  "vue-drag-scroller"
</script>

<template>
    <div v-drag-scroller>
    </div>
</template>

Register in Nuxt:

// plugins/vue-drag-scroller.js
import VueDragScroller from 'vue-drag-scroller'

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

Config🔖

Options:

you can pass options to directive like this:

<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>

| 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:

<template>
    <div v-drag-scroller.onlyX>
    </div>
</template>
<template>
    <div v-drag-scroller.disablechild>
    </div>
</template>

| 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

<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>
  • Events Listener with v-on or @

Example with @

<template>
    <div v-drag-scroller
      @scrollStart="onScroll"
      @scrollEnd="onEndScroll"
      @scrollMoving="onScrolling"
    >
    </div>
</template>

Example with v-on

<template>
    <div v-drag-scroller
      v-on:scrollStart="onScroll"
      v-on:scrollEnd="onEndScroll"
      v-on:scrollMoving="onScrolling"
    >
    </div>
</template>
  • Drag parent except all child

Example

<template>
    <div v-drag-scroller.disablechild>
        <div class="child">
        </div>
        <div class="child">
        </div>
    </div>
</template>
  • Drag parent except particular child

Example

<template>
    <div v-drag-scroller>
        <div class="child" drag-scroller-disable> // disable drag scroll
        </div>
        <div class="child">
        </div>
    </div>
</template>
  • Only scroll in X axis

Example

<template>
    <div v-drag-scroller.onlyX>
    </div>
</template>
  • Only scroll in Y axis

Example

<template>
    <div v-drag-scroller.onlyY>
    </div>
</template>
  • Hide scrollbar

Example

<template>
    <div v-drag-scroller={
      hideScrollbar: true
    }>
    </div>
</template>
  • Change speed of scroll

Example

<template>
    <div v-drag-scroller={
      speed: 0.5 // default is 1
    }>
    </div>
</template>
  • Change direction of scroll

Example

<template>
    <div v-drag-scroller={
      reverseDirection: true
    }>
    </div>
</template>