Skip to content

Commit

Permalink
modifiers: add short README
Browse files Browse the repository at this point in the history
  • Loading branch information
taye committed Jun 1, 2018
1 parent 1404c17 commit 6778e44
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/modifiers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# modifiers

Use modifiers to change the coordinates of drag, resize and gesture events.

The `options` object passed to the action methods can have a `modifiers` array
which will be applied to events of that action type.

```js
// create a restrict modifier to prevent dragging an element out of its parent
const restrictToParent = interact.modifiers.restrict({
restriction: 'parent',
elementRect: { left: 0, right: 0, top: 1, bottom: 1 },
})

// create a snap modifier which changes the event coordinates to the closest
// corner of a grid
const snap100x100 = interact.modifiers.snap({
targets: [interact.snappers.grid({ x: 100, y: 100 })],
}),

// apply the restrict and then the snap modifiers to drag events
interact(target).draggable({
modifiers: [restrictToParent, snap100x100],
})
```

0 comments on commit 6778e44

Please sign in to comment.