Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

xnap

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xnap

Components that snap.

latest
Source
npmnpm
Version
1.5.1
Version published
Maintainers
1
Created
Source

Xnap

Components that snap.

Demo

https://memeone.github.io/xnap/

Demo Gif

npm i --save xnap

How do i use it?

For a full example, check out /example. Here's a simple example that snaps between transformX(-100%) and transformX(100%).

let xnapCard = new Xnap(component, { states: ['-100% + ', '100% + '], direction: 0 })
xnapCard.register() // Register the event listeners.

Options

new Xnap(component, { options })
NameTypeDefaultDescription
exactBooleanfalseIf dragging should only be triggered when you touch the component xnap was mounted on.
stateBooleanfalseWhich state the component is initiated with.
statesString Array['0% + ', '100% + ']What the transforms are for the states. Movement is appended to the current string.
scaleStatesNumber Array[1.0, 1.0]What the scales are for the states.
factorNumber5How snappy it is. Higher = Snappier.
lengthNumber100How far it needs to be dragged before it snaps.
onTrueFunctionNoneFunction that triggers when state is set to true.
onFalseFunctionNoneFunction that triggers when state is set to false.
conditionFunction() => trueRuns on mouse/touch down, if false return: don't trigger moving.
directionNumber1Which direction it moves. 0 = Left/Right. 1 = Up/Down.
vibrateNumberNoneIf a number is given, it vibrates the device on state change for the given duration in MS. Use 2 - 5 for a clicky tap.

Keywords

Touch

FAQs

Package last updated on 04 Dec 2020

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