Code Monkey home page Code Monkey logo

wheel-indicator's Introduction

wheel-indicator

Indicates when user makes swipe gesture on a trackpad or mouse wheel.

Build Status

trackpad

Installing

npm i -S wheel-indicator

or oldschool method:

<script src="wheel-indicator.js"></script>

Usage

var WheelIndicator = require('wheel-indicator'); // โ† if you use build system

var indicator = new WheelIndicator({
  elem: document.querySelector('.element'),
  callback: function(e){
    console.log(e.direction) // "up" or "down"
  }
});

//The method call
indicator.getOption('preventMouse'); // true

API

Options

Field Type Default value Mutable (by setOptions()) Description
elem Object (dom node) document No DOM node to listen wheel event on.
callback Function - Yes The callback, which will be triggered on gesture. Gets for the first argument a native wheel event object, extended by direction property, taking value 'up' or 'down'.
preventMouse Bool true Yes Disables mouse wheel working. In other words applies preventDefault() to wheel event.

Instance methods

Method Description
turnOff() Turns off callback triggering.
turnOn() Turns on callback trigerring.
setOptions(options) Sets the mutable options. The only argument must be Object.
getOption('option') Returns option value. The only argument must be String.
destroy() Removes event listener.

wheel-indicator's People

Contributors

f0rmat1k avatar ulitcos avatar frux avatar noveogroup-amorgunov avatar rkit avatar shevchenkoalexen avatar mrsamo avatar vetoshko avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.