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

smooth-vuebar

v1.4.0

Published

Vue directive wrapper for smooth-scrollbar

Downloads

132

Readme

smooth-vuebar

Vue directive wrapper for smooth-scrollbar

Demo

You can refer to the wrapped library's demo.

Why

There are many other wrappers for this library but none of them implements the original library as directive.

I think directives are the right way to handle this kind of DOM manipulation, so let it be.

Also, there are so many problems I found while trying SSR that the only available choice for me was doing it by myself.

Install

npm i smooth-vuebar

Vue.use(SmoothVuebar)

SSR (nuxt): install as client plugin

Safari and IE: this library requires a CustomEvent polyfill.

Usage

Usually this plugin is used app-wide.

Vue

<template>
  <div>
    <div v-smoothscrollbar="{ listener, options }">
      <router-view />
    </div>
  </div>
</template>

Nuxt & Gridsome

this is a default.vue layout:

<template>
  <div>
    <div
      v-smoothscrollbar="{ listener, options }"
      @insert=".."
      @unbind="..">
      <nuxt />
    </div>
  </div>
</template>

However, you can use it where you want, just mind the default css:

.smooth-vuebar {
  max-width: 100vw;
  max-height: 100vh;
}

And replace it as you wish.

Options

The directive can be customized passing an object.

<div v-smoothscrollbar="{ listener, options }">
  • listener (default: undefined) => can be a function, it will automatically set as listener.

  • options (default: undefined) => can be an object.

Please refer to the offical API docs.

Events

The directive implements two extra events, useful when you want to retrieve the Scrollbar istance and use it.

  • @insert - fired when the DOM element is inserted and the library is loaded on it. The callback may be a function (e).

  • @unbind - fired when the DOM element is unbound and the library is unloaded. The callback may be a function (e).

Extra

You can define global default options. They are valid only if you don't set any local option.

Try it:

Vue.use(SmoothVuebar, {
  listener: () => {},
  options: {}
})

Play with the core

If you want to use the actual wrapper library, here is an helper, available in every component:

this.$scrollbar

Or project-wide

import Vue from 'vue'

Vue.scrollbar

Refer to offical API docs.