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

@awey/scroller

v2.3.2

Published

The best custom scroll bar

Downloads

530

Readme

scroller

The best custom scroll bar. Can be nested.

I used it in my vue ui components library Admin-Ui. If you want to use it in vue or react, maybe you can look up the source of Admin-Ui Scroller

Attension: Scroller has been rewritten with typescript since version 2

install

Scroller can be installed by npm or yarn.

yarn install @awey/scroller

Or you can just install it as a script tag.

<script src="path-of-scroller/lib/scroller.iife.js"></script>

Useage

.custom-track-style {
  background: red;
}
.custom-bar-style {
  background: blue;
}
<div id="container">
  <div style="width: 1200px; height: 1200px;"></div>
</div>
import Scroller from 'scroller'
import from 'scroller/lib/style.css'

const myScroller = new Scroller({
  el: document.getElementById('container'),
  direction: 'both',
  offset: 4,
  scaleable: true,
  trackClassName: 'custom-track-style',
  barClassName: 'custom-bar-style'
})

Note: All the children in container element should be element nodes (nodeType === 1). All the other types will be ignored.

Options

  • el: DOMElement, required, a container element which you want to made it a custom scrollbar
  • direction: String, optional, determine which direction you would like to scroll. it support values below.
    • both: default value
    • horizontal
    • vertical
    • none
  • offset: Number, optional, the space between scroll bar and element edge, max is 8 and min to 0, the default is 4
  • scaleable: Boolean, optional, determine if the scroll bar width can enlarge or not when user hovering over the element
  • trackClassName: String, optional, you can use it to customize the track style
  • barClassName: String, optional, you can use it to customize the bar style

Methods

  • Scroller(options): Constructor, it returns an instance of scroller
  • scroller.setDirection(direction): Set scroll direction, it returns an instance of scroller
  • scroller.getScroll(): Return current scrollTop and scrollLeft value
  • scroller.onScroll(callback): Bind a scroll event listener to instance, the callback recieves an Event object which is the native scroll event object. It returns current scroll instance
  • scroller.offScroll(callback): Unbind a scroll event listener to instance, the callback recieves an Event object which is the native scroll event object. Omitting callback will unbind all the scroll event listener. It returns current scroll instance
  • scroller.scrollTo(position): Let scroller scroll to the specified position. It returns current scroll instanc. positions is an object which contains keys below
    • scrollTop: Optional
    • scrollLeft: Optional
  • scroller.destroy(): Instance method, use it to destroy a scroller instance