1.0.1 ā€¢ Published 4 years ago

edge-scroller v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago
import { EdgeScroller } from "edge-scroller";

const boxElement = window.document.getElementById("box");
const edgeScroller = new EdgeScroller(boxElement, { offset: 80, scrollSpeedCoefficient: 0.8 });
edgeScroller.enable();

Table of Contents

Features

FEATURESWHAT YOU CAN DO
šŸ–±ļø Available anywhereYou can use while drag and drop or others
šŸ’Ž No DependenciesAll you need is adding this package
šŸŽ© Type SafeYou can use with TypeScript

Quick Start

Requirements

  • npm or Yarn
  • Node.js 10.0.0 or higher

Installation

$ npm install edge-scroller

If you are using Yarn, use the following command.

$ yarn add edge-scroller

Setup

Firstly import EdgeScroller class from this package and give a scrollable element which has overflow: scroll; style such as to a constructor. Then you can switch to enable and disable via enable() or disable() methods.

import { EdgeScroller } from "edge-scroller";

const boxElement = window.document.getElementById("box");
const edgeScroller = new EdgeScroller(boxElement);

// To enable.
edgeScroller.enable();

// To disable.
edgeScroller.disable();

API

EdgeScroller.constructor

import { EdgeScroller } from "edge-scroller";

const edgeScroller = new EdgeScroller(boxElement, { offset: 80, scrollSpeedCoefficient: 0.8 });

This creates a new instance object of EdgeScroller class.

  • targetElement: HTMLElement
    • Required.
    • The target scrollable element. If the element is not scrollable, edge-scroller does not work fine.
  • options: Options
    • Optional, a default value is {} .
    • offset: number
      • Optional, a default value is 50 .
      • An offset value to begin scrolling.
    • offscrollSpeedCoefficientset: number
      • Optional, a default value is 0.5 .
      • A coefficient of scroll speed.

EdgeScroller.prototype.enable

const edgeScroller = new EdgeScroller(boxElement);
edgeScroller.enable();

This enables automatic scrolling.

EdgeScroller.prototype.disable

const edgeScroller = new EdgeScroller(boxElement);
edgeScroller.disable();

This disables automatic scrolling.

Contributing to edge-scroller

Bug reports and pull requests are welcome on GitHub at https://github.com/jagaapple/edge-scroller. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Please read Contributing Guidelines before development and contributing.

License

The library is available as open source under the terms of the MIT License.

Copyright 2020 Jaga Apple. All rights reserved.