Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

impetus-fp

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

impetus-fp

Impetus.js ========= Add momentum to anything. It's like iScroll, except not for scrolling. Supports mouse and touch events.

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Impetus.js

Add momentum to anything. It's like iScroll, except not for scrolling. Supports mouse and touch events.

Check out the demos on the home page.

Impetus will probably never support anything other than simple momentum. If you need scrolling or touch carousels or anything like that, this probably isn't the tool you're looking for.

Usage

var myImpetus = new Impetus({
    source: myNode,
    update: function(x, y) {
        // whatever you want to do with the values
    }
});

You give it an area to listen to for touch or mouse events, and it gives you the x and y values with some momentum.

Impetus will register itself as an AMD module if it's available.

Constructor Options

TypeDefaultDescription
sourceHTMLElement|StringdocumentElement reference or query string for the target on which to listen for movement.
update (required)function(x, y)-This function will be called with the updated x and y values.
multiplierNumber1The relationship between the input and output values.
frictionNumber0.92Rate at which values slow down after you let go.
initialValues[Number, Number][0, 0]Array of initial x and y values.
boundX[Number, Number]-Array of low and high values. x-values will remain within these bounds.
boundY[Number, Number]-Array of low and high values. y-values will remain within these bounds.
bounceBooleantrueWhether to stretch and rebound values when pulled outside the bounds.

Methods

Description
.pause()Disable movement processing.
.resume()Re-enable movement processing.
.setMultiplier( <number> )Adjust the multiplier in flight.
.setValues( <number> , <number> )Adjust the current x and y output values.
.setBoundX( <number[2]> )Adjust the X bound
.setBoundY( <number[2]> )Adjust the Y bound
.destroy() This will remove the previous event listeners. Returns null so you can use it to destroy your variable if you wish, i.e. instance = instance.destroy()
.getValueX() This will return current position X instance = instance.getValueX()
.getValueY() This will return current position Y instance = instance.getValueX()

Browser Support

Chrome, Firefox, Safari, Opera, IE 9+, iOS, Android. Support for IE 8 can be achieved by adding a polyfill for addEventListener.

Keywords

FAQs

Package last updated on 17 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc