JSPM

@mr-scroll/core

0.1.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q39869F
  • License MIT

The best custom scroll for the web. This is the core package.

Package Exports

  • @mr-scroll/core

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@mr-scroll/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@mr-scroll/core

npm License

The best custom scroll for the web.

This is the core package. Check here for a general usage guide.

Implementation

NOTE: If you're using a framework we have a wrapper for then you don't need this. Check here to see which ones we support.

@mr-scroll/core has the core logic to make an mr-scroll custom scrollbar.

Implementing @mr-scroll/core in a framework is simple. You'll wrap the Scroll class inside your component (or something similar).

The Scroll constructor takes 3 arguments:

  • Host element: The html element that will act as the host. Required.
  • Content element: The html element that will contain the actual contents. Required.
  • A config object

So this requires you to provide the host and content elements. As an example you could have this html template:

<div> <!-- host element -->
  <div> <!-- content element -->
    CONTENT
  </div>
</div>

Use whatever is the idiomatic approach in your framework to do this.

And then in your wrapper component:

import { Scroll } from '@mr-scroll/core';

// Inside the wrapper

// You'll want to store the reference to the scroll
this.scroll = new Scroll(hostElement, contentElement, /* config: fill from your inputs */ { ... });

// Initialize whenever is the right time to do so in your framework
this.scroll.initialize();

// And don't forget to destroy it when your component is being destroyed
this.scroll.destroy();

This package also provides the main CSS styles to be imported in your app. You can find the bundled styles at "@mr-scroll/core/dist/styles.css".

Check our angular wrapper to see an example of all of this for Angular.

Release notes

0.1.0

Initial version.