-
Notifications
You must be signed in to change notification settings - Fork 786
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #625 from taye/modifiers-array
Per-action modifiers array
- Loading branch information
Showing
18 changed files
with
622 additions
and
447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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], | ||
}) | ||
``` |
Oops, something went wrong.