1.5.1 • Published 3 years ago

xnap v1.5.1

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

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 Array1.0, 1.0What 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.
1.5.1

3 years ago

1.5.0

3 years ago

1.4.0

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago